gdi / curb-fu

Simple, yet powerful wrapper for taf2's curb (libcurl) library
Other
57 stars 9 forks source link

how do I pass headers, URL, and data? #16

Closed angelacode closed 9 years ago

angelacode commented 9 years ago

This is what I did based on the documentation:

response = CurbFu.post(:url => url, payload, :headers => {'Content-Type' =>'application/json',
                                                                  'Authorization' => "Bearer #{token}" })

But it's expecting a hash....

hypomodern commented 9 years ago

Howdy!

Something like this:

response = CurbFu.post({ :url => url, :headers => { 'Content-Type' => 'application/json' } }, payload)

should work!

angelacode commented 9 years ago

thank you trying it now...!

angelacode commented 9 years ago

hm, this is what I tried prior...and it didn't work....trying again...

angelacode commented 9 years ago

I still get the same error:

HTTP Status 400 - Bad Request

But curl works:

curl "https://api-sandbox.billforward.net:443/v1/subscriptions/SUB-35F07614-4F6D-4AF2-95EB-F3DB03FE/advance" \
    -H "Authorization: Bearer token-here" \
    -H "Content-Type: application/json" \
    -d \
'{
  "to": "2015-11-22T19:26:15Z",
  "skipIntermediatePeriods": true,
  "handleAmendments": false
}'
angelacode commented 9 years ago

This is what I tried:

response = CurbFu.post({ :url => url, :headers => { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{token}" } }, payload_json)

I believe this is the same as what you did and I still get a bad formed request....

angelacode commented 9 years ago

seeing that the format of the raw JSON isn't the same as when using curl....