1

Im trying to send out a POST request using AWS. My issue is that I keep getting Error 400: Bad request. Any help is greatly appreciated!

url = 'https://api.samanage.com/incidents.json' # Set destination URL here
post_fields = {
    'incident': {
        'name': 'practice tickets for alexa',
        'priority': 'LOW',
        'requester': {
            'email': '[email protected]'
        }
    }
}     # Set POST fields here

headers = {
    'cookie': 'rbzid=OquMLWfcbKxn7DHPYXDBAb6%2Bg%2FS7%2FMkG5RPBxCSy5tRDToqbLchk3q4HUPyH%2FFJ1ykIrbT7gAhVigPk9n8dmrt%2BxzZwOnF5g9Gby2ljY%2FGk%3D',
    'content-type': 'application/json',
    'x-samanage-authorization': 'Bearer **Token**',
    'accept': 'application/vnd.samanage.v2.1+json'
}

request = Request(url, urlencode(post_fields).encode(), headers=headers)
json = urlopen(request).read().decode()
print(json)
1
  • It's also worth noting that if I take the headers out completely then I get a 401 Unauthorized error code Commented Jun 14, 2018 at 17:17

1 Answer 1

1

Turns out this isn't possible in the AWS in line text editor. I had to download the AWS CLI and create lambda function from the CLI

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.