Unable to resolve " not a valid key=value pair (missing equal-sign) in Authorization header" when POSTing to api gateway
Solution 1
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))
Solution 2
I have run across this error when the resolved URL was incorrect. (Or without a proxy but with an incorrect URL.)
Solution 3
For me the reason why it didn't work is because I didn't redeploy when making changes to the integration.
So if you use terraform to create resources, you need to include the triggers
part. See: https://www.terraform.io/docs/providers/aws/r/api_gateway_deployment.html#redeployment-triggers
Solution 4
I had faced the same issue. For me, the issue was due to a case-sensitive url. Please make sure, the spelling and the casing of each of the words are correct.
Solution 5
in my case very similar, using third api payment has wrong set on request TYPE , instead of delete i use post. ah my bad.
Comments
-
Tesuji almost 2 years
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?