1
Hello,
I am doing some simple tests for integration of the API Gateway with Dynamodb, at this moment I can do a GET and POST using POSTMAN and GET in python, but I cannot do the POST in Python, I have a bug
One or more Parameter values Were invalid: An Attributevalue may not contain an Empty string
(returns from AWS) but I can’t verify what is going empty being that the body of the request is the same as I use in POSTMAN.
Has anyone gone through this or has any idea if it might be some wrong parameter in python ?
follows screen:
import requests
import json
###################################################
####ETAPA - CHAMADO API PARA POST##################
###################################################
print('10º ETAPA - CHAMADO API POST')
payload = [
{
"id": 10,
"cont_id": "Monday",
"idade": 15,
"name": "Test with python",
}
]
print(str(payload))
try:
#chamar API POST
url = 'https://bswv8.execute-api.us-east-2.amazonaws.com/dev/gravar'
print('URL API Post: ', url)
headers = {
"Content-Type": "application/json",
'Accept': 'application/json'
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
except Exception as e:
print('ETAPA: ERRO ac chamar API para o POST')
finally:
print('ETAPA: Chamada a API POST bem sucedido')
Thanks for your help
Abs
Please edit the question and put your code as code, not as image (paste here and use the button
{}
to format. Do the same with the full error message.– jsbueno
HI @jsbueno. Done and thanks for the guidance..
– Rodolfo Sousa
Two things: 1) your JSON is not properly formatted (it has a comma after the last parameter - after "Test with python"); 2) you have already run the test trying to pass
data=payload
instead ofjson=payload
?– Murilo Sitonio
Hi @Murilositonio, thanks for the reply. I tried to change the 'json=payload' to 'data=payload' but the error remains the same, saying that I am passing an empty string, even after having taken the comma according to its orientation. Actually when I change to 'data=payload' it can’t even reach the API, IE, nor have the return of the empty string
– Rodolfo Sousa