Unable to resolve " not a valid key=value pair (missing equal-sign) in Authorization header" when POSTing to api gateway

Tesuji

I created an api-gateway to put data in my s3 bucket. When I test it in console it works with no problem. Even when I test my token in the authorizer test it returns an "Allow", so there's nothing wrong with my token. My token validation is

^Bearer [-0-9a-zA-z\.]*$

so my python code for generating my header looks like this:

headers = {
    "Authorization": "Bearer " + token,
    "Content-type": "application/json"
}

The rest of my code is:

response = requests.post(url, headers=headers, data={"id":"0678a93d-ee8c-4db5-a831-1e311be4f04b", "test":"12345"})
print(response.text)

The error message I get is "{"message":"'{My Token}' not a valid key=value pair (missing equal-sign) in Authorization header: 'Bearer {My Token}'."}"

My url looks like this:

https://my-api-gateway.amazonaws.com/MyStage, and I am using a {proxy+} in my resources. I noticed if I change my header from Content-type to Accept, it gives me the same error, but if I also change my url to https://my-api-gateway.amazonaws.com/MyStage/any-arbitrary-string/, I get a

   {"response":{"status":"VALID", "message": "success"}} 

but the file does not show up in my s3 bucket. How do I resolve this?

Tesuji

I resolved it. I changed my method to come from the root resource (instead of the unnecessary {proxy+}, and also noticed that my python method was incorrect. I had response = requests.post(url, headers=headers, data=my_json), but data only accepts a string. I have to use either requests.post(url, headers=headers, json=my_json) or requests.post(url, headers=headers,data=json.dumps(my_json))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

AWS Signature Error using Postman to access the AWS API Gateway when posting a binary

From Dev

Posting from AWS-API Gateway to Lambda

From Dev

When posting to my Django API : errorcom.google.gson.JsonParseException: unable to parse json

From Dev

Posting form-data and binary data through AWS API Gateway

From Dev

Vue Js: empty string when posting to API

From Dev

Spring cloud gateway unable to resolve service id from eureka server

From Dev

Unable to access cookies when posting from different site in .net core

From Dev

unable_to_verify_leaf_signature when posting from AngularJs/Cordova

From Dev

Unable to resolve "A generic error occurred in GDI+" when save image in Web API

From Dev

Unable to configure Firebase authorization to AWS API Gateway

From Dev

Unable to test Lambda Integration on API Gateway Console

From

Unable to create a stage in AWS API Gateway

From Dev

AWS API gateway unable to execute lambda?

From Dev

Unable to run AWS Lambda function with API Gateway

From Dev

Amazon API Gateway unable to call Lambda in VPC

From Dev

Mysterious Rails 5 API LoadError for model when posting JSON; no error when posting as form-data

From Dev

Unable to resolve Generic error in REST API

From Dev

AWS API Gateway: When to create another API?

From Dev

Unable to resolve ${...} in @PropertySource when using Spring boot

From Dev

Unable to resolve service for type when mapping

From Dev

Unable to resolve module when trying to build

From Dev

Unable to resolve service when using DI

From Dev

GCE - HTTP Load Balancing returns Error 502 (Bad Gateway) - Only When Posting via C#

From Dev

Get null when posting data on an API via PHP curl

From Dev

javascript: Serialize/deserialize class instance when posting to api

From Dev

How to return identity value from Web API when posting to the database

From Dev

Unexpected token error when POSTing to Shopify's Billing API

From Dev

How to neglect emojis when posting messages to slack using slack api?

From Dev

Time out issue when posting json data to node api

Related Related

  1. 1

    AWS Signature Error using Postman to access the AWS API Gateway when posting a binary

  2. 2

    Posting from AWS-API Gateway to Lambda

  3. 3

    When posting to my Django API : errorcom.google.gson.JsonParseException: unable to parse json

  4. 4

    Posting form-data and binary data through AWS API Gateway

  5. 5

    Vue Js: empty string when posting to API

  6. 6

    Spring cloud gateway unable to resolve service id from eureka server

  7. 7

    Unable to access cookies when posting from different site in .net core

  8. 8

    unable_to_verify_leaf_signature when posting from AngularJs/Cordova

  9. 9

    Unable to resolve "A generic error occurred in GDI+" when save image in Web API

  10. 10

    Unable to configure Firebase authorization to AWS API Gateway

  11. 11

    Unable to test Lambda Integration on API Gateway Console

  12. 12

    Unable to create a stage in AWS API Gateway

  13. 13

    AWS API gateway unable to execute lambda?

  14. 14

    Unable to run AWS Lambda function with API Gateway

  15. 15

    Amazon API Gateway unable to call Lambda in VPC

  16. 16

    Mysterious Rails 5 API LoadError for model when posting JSON; no error when posting as form-data

  17. 17

    Unable to resolve Generic error in REST API

  18. 18

    AWS API Gateway: When to create another API?

  19. 19

    Unable to resolve ${...} in @PropertySource when using Spring boot

  20. 20

    Unable to resolve service for type when mapping

  21. 21

    Unable to resolve module when trying to build

  22. 22

    Unable to resolve service when using DI

  23. 23

    GCE - HTTP Load Balancing returns Error 502 (Bad Gateway) - Only When Posting via C#

  24. 24

    Get null when posting data on an API via PHP curl

  25. 25

    javascript: Serialize/deserialize class instance when posting to api

  26. 26

    How to return identity value from Web API when posting to the database

  27. 27

    Unexpected token error when POSTing to Shopify's Billing API

  28. 28

    How to neglect emojis when posting messages to slack using slack api?

  29. 29

    Time out issue when posting json data to node api

HotTag

Archive