3bluedata

curl POST problem 400

Discussion created by 3bluedata on Apr 5, 2018
Latest reply on Apr 6, 2018 by wimdecorte

I create a curl request to SMS skebby.com service following their documentations.

I need a two request, the first request is for recover user key and session key. This call is successfull and the result is ok.

The first request is

# Session Key example
curl -XGET 'https://api.skebby.it/API/v1.0/REST/login?username={username}&password={password}' -H 'Content-Type: application/json'

It's OK.

 

After i request a send SMS, this is a skebby documentation about it:

# Session Key example
curl -XPOST 'https://api.skebby.it/API/v1.0/REST/sms' -H 'Content-Type: application/json' \
-H 'user_key: {USER_KEY}' -H 'Session_key: {SESSION_KEY}' -d'
{
  "returnCredits": true,
  "order_id": "123456789",
  "recipient": [
  "+393471234567",
  "+393471234568"
  ],
  "scheduled_delivery_time": "20161223101010",
  "message": "Hello world!",
  "message_type": "GP",
  "sender": "MySender"
}
'

In filemaker create a variable $url=https://api.skebby.it/API/v1.0/REST/sms

After create variable $json and use wimdecorte Esperto technique and functions.

_cURL_request ( "POST" ) &

_cURL_header ( "Content-Type" ; "application/json" ) & " \\¶" &

_cURL_header ( "user_key" ; Anagrafiche::User_KEY ) &

_cURL_header ( "Session_key" ; Anagrafiche::Session_KEY ) &

" -d" & $Elem_Dat

 

where $Elem_Dat =

"'" &

JSONSetElement ( "{}" ;

[ "recipient" ; $json_array ; JSONArray ] ;

[ "message" ; "Hello world" ; JSONString ] ;

[ "message_type" ; "GP" ; JSONString ]

) & "'"

 

the result is $json =

-X POST -H "Content-Type: application/json" \

-H "user_key: 4004XXX" -H "Session_key: A2468E705F2771DF67DE27811B739C25EDF3A4F0A4611AB113CD9791E2425494" -d'{"message":"Hello world","message_type":"GP","recipient":["+39340173XXXX"]}'

 

when i request with Insert from URL i specific the url with $url and cURL options with $json but the response is always

{"error_type":"UnknownErrorException","code":400,"error_message":"Unknown error"}

 

I made several attempts for this request but anything, the error 400 persists

 

Any suggestion... thanks.

Outcomes