0
votes

I have a python app that is giving a HTTP 500 when I run it. If I call the same API from a different app it works fine. If I remove the token variable from Authorization header I will get a 401, so it seems I may have a formatting issue somewhere but not seeing it.

token = r.text

incurl= "https://api-url"

data = {
"values": {
    "First_Name": "name",
    "Last_Name":"name",
    "z1D_Action": "CREATE",
    "Status":"Assigned",
    "Service_Type":"User Service Restoration",
    "Impact": "4-Minor/Localized",
    "Urgency": "3-Medium",
    "Description":"Missing Call Type",
    "Reported Source": "Direct Input",
    "Detailed_Decription":"Missing Call Type. Look at the Application Event Viewer on <server_name>.",
    "Assigned Support Company":"work",
    "Assigned Support Organization":"Global Operations",
    "Assigned Group":"Team A",
    "Product Categorization Tier 1":"Telecom",
    "Product Categorization Tier 2":"Software",
    "Product Categorization Tier 3":"Call Center",
    "Categorization Tier 1":"Failure/Repair",
    "Categorization Tier 2":"Missing Data/Modify",
    "Product Name":"UCCE"
    }
}

hdr = {
    'Content-Type': 'application/json',
    'Authorization': token
      }
r=requests.post(incurl, headers=hdr, json=data)
print('Incident Request Status:', r.status_code)
This seems difficult for the anyone else to help debug if you can't provide the API URL. Did you try this exact same payload in another app and it worked? What is 'the other app'? - wkl
HTTP codes in a nutshell: 1xx - to let you know, 2xx - fine, 3xx - not here, 4xx - you failed, 5xx - server failed - Klaus D.
Capture the request the other app is making. It’s possible that the data you include has a different data shape than you expect. In either case the app receiving the request seems buggy—it shouldn’t raise a 500 over then format of your request, rather, it should return an error with some context useful for remediation. - pygeek