Ruby/Rack/Sinatra encoding of a MessagePack POST -


I'm trying to create an API with Sinatra and MessagePack, but I'm ready to shoot myself: )

So I'm using curl to post:

  curl -x post-h "content-type: application / x-messagepack" - Data-Binary '\ x82 \ xA4uuid \ xBD8asd76a -a8s7a6d87-asd76as8d76 \ xABcampaign_id \ xA12' http: // localhost: 9393 /  

Now I do just in Sinatra:

  MessagePack.unpack requests body.read  

and this is free The error goes to error:

  MessagePack :: malformedFormatError exception: follow the additional bytes after a deserialized object  

because request.body.read Coming back:

  "I \\\\\\\ xxxx \ xA4uuid \\ xBD8asd76a-a8s7a6d87-asd76as8d76 \\ xABcampaign_id \" xA12 "instead of" I " :: Binari) and tried to think about other stupid things. And I'm not sure who's causing Ruby, Rack or Papara problem?   

What is the problem with the command line for curl - data-binaries It does not process it in a byte value by using syntax like Ruby; it does not process it as letter (which is the "\\ x82" looks like if you inspect the string in the strobe).

@filename Instead of the syntax for the curl, and save the data file that you created using Message Packs (in the Ruby 'wb' be sure to set mode):

  curl -x post-h "content-type: app / x-msgpack" --Data-binary @ test.dat http: // Localhost: 9393 /  

To create a Ruby test file: ("8asd76a-a8s7a6d87-asd76as8d76", "campaign_id" = "2") File.open ('test.dat', < / P>

  messages = messagePack.Pack ("UUID" => "8asd76a-a8s7a6d87-asd76as8d76" 'Wb') Run | file | file.write (msg) end  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -