Oct-01-2021, 08:04 AM
I have this request example :
curl –X POST https://api.apifonica.com/v2/accounts/{a...}/messages \
-H 'Content-Type: application/json' \
-d '{
"from": "35315313424",
"to": "447860041755",
"text": "Apifonica API provides a really cool SMS messaging service"
}' \
-u {accountSID}:{authToken}
I have already coded it this way using the python request module
but I'm having this error :
Please check the brackets and quotes in your request.''
I don't know where I'm wrong with my syntax, I have already research on other questions similar to this my own here on this forum and on google but couldn't figure out the solution
curl –X POST https://api.apifonica.com/v2/accounts/{a...}/messages \
-H 'Content-Type: application/json' \
-d '{
"from": "35315313424",
"to": "447860041755",
"text": "Apifonica API provides a really cool SMS messaging service"
}' \
-u {accountSID}:{authToken}
I have already coded it this way using the python request module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import requests from requests.auth import HTTPBasicAuth h = { "Content-Type" : "application/json" } d = { "from" : "35315313424" , "to" : "447860041755" , "text" : "Apifonica API provides a really cool SMS messaging service" } u = HTTPBasicAuth( 'my accountSID' , 'my authToken' ) result = requests.post(url, auth = u ,data = d, headers = h) print (result.text) |
Error:{"status_code":400,"error_code":10001,"error_text":"Bad Request","uri":"https://www.apifonica.com/en/docs/api/rest/errors#10001"}
The error code reference from the API provider said that ''The request could not be understood by the Apifonica server due to malformed syntax.Please check the brackets and quotes in your request.''
I don't know where I'm wrong with my syntax, I have already research on other questions similar to this my own here on this forum and on google but couldn't figure out the solution