Python Forum
how can I correct the Bad Request error on my curl request
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how can I correct the Bad Request error on my curl request
#6
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/aa9999/messages",
    headers=headers,
    data=data,
    auth=("aa9999", "111111"),
)

print(response.content)
Output:
b'{"status_code":401,"error_code":10010,"error_text":"Unauthorized","uri":"https://www.apifonica.com/en/docs/api/rest/errors#10010"}'
If run this code do you get error 10012?
I do get 10010 Unauthorized as except as i have not have signed up and gotten accountSID and token.
Reply


Messages In This Thread
RE: how can I correct the Bad Request error on my curl request - by snippsat - Oct-02-2021, 09:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Triggering a ps1 script in remote windows server via http python request jasveerjassi 1 528 Jan-26-2024, 07:02 PM
Last Post: deanhystad
  Is it possible to add a delay right after a request.get() cubangt 6 3,870 Sep-07-2023, 09:29 AM
Last Post: shoesinquiry
  How would I alter this to a single api request? SuchUmami 1 881 Jun-24-2023, 08:30 AM
Last Post: ferdnyc
  Request Dependency warning thetechnodino 0 1,015 Dec-20-2022, 02:12 AM
Last Post: thetechnodino
  How to output one value per request of the CSV and print it in another func? Student44 3 1,527 Nov-11-2022, 10:45 PM
Last Post: snippsat
  Unable to request image from FORM Data usman 0 1,077 Aug-18-2022, 06:23 PM
Last Post: usman
  Repeat request by else stsxbel 2 1,303 Jul-30-2022, 03:34 PM
Last Post: stsxbel
  How do loop over curl and 'put' different values in API call? onenessboy 0 1,349 Jun-05-2022, 05:24 AM
Last Post: onenessboy
  request.get to read large response pythonlearner1 7 3,555 Apr-05-2022, 08:21 PM
Last Post: pythonlearner1
  alternative to using request module in python vlearner 2 1,444 Feb-05-2022, 09:35 AM
Last Post: ibreeden

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020