Oct-01-2021, 01:21 PM
(Oct-01-2021, 09:05 AM)snippsat Wrote: Try this.
import requests headers = { "Content-Type": "application/json", } data = '{\n"from": "35315313424",\n"to": "447860041755",\n"text":\ "Apifonica API provides a really cool SMS messaging service"\n}' response = requests.post( "https://api.apifonica.com/v2/accounts/%7BaccountSID%7D/calls", headers=headers, data=data, auth=("{accountSID}", "{authToken}"), )Or with HTTPBasicAuth.
import requests from requests.auth import HTTPBasicAuth headers = { "Content-Type": "application/json", } data = '{\n"from": "35315313424",\n"to": "447860041755",\n"text":\ "Apifonica API provides a really cool SMS messaging service"\n}' u = HTTPBasicAuth('my accountSID' , 'my authToken') response = requests.post( "https://api.apifonica.com/v2/accounts/%7BaccountSID%7D/calls", headers=headers, data=data, auth=u, )
I have tried it but i have this error on both the HTTPBasicAuth and the normal request
Error:{"status_code":400,"error_code":10012,"error_text":"Validation error. Please enter valid parameter values.","parameters":["accountSID"],"errors":{"accountSID":["SID length is invalid."]},"uri":"https://www.apifonica.com/en/docs/api/rest/errors#10012"}