robotframework-requests
robotframework-requests copied to clipboard
Words pt-br with accents is causing 400 Bad Request on the new Post/Put On Session
I'm migrating some tests with Get/Post/Put Requests to the new Get/Put/Post On Session, but I'm having difficulty with strings with accents (pt-br). See below in the image. What should I do?
Python 3.9.0 requests 2.25.1 requests-oauthlib 1.3.0 robotframework 4.0.2 robotframework-pythonlibcore 2.1.0 robotframework-requests 0.9.1
That's most probably because you're using the data= parameter instead of json= try to swap those parameters.
@lucagiove The same error occurred, however after I converted the String to JSON, it worked.
Alterar o livro "${ID_LIVRO}"
# Na versão atual da Library Requests, o Put Request foi substituído por Put On Session
# E foi acrescentado o argumento expected_status
${JSON_BODY} To Json {"id":${BOOK_150.ID},"title":"${BOOK_150.Title}","description":"${BOOK_150.Description}","pageCount":${BOOK_150.PageCount},"excerpt":"${BOOK_150.Excerpt}","publishDate":"${BOOK_150.PublishDate}"}
${RESPOSTA} Put On Session fakeAPI Books/${ID_LIVRO}
... json=${JSON_BODY}
... headers=${HEADERS} expected_status=any
# ${RESPOSTA_2} Put Request fakeAPI Books/${ID_LIVRO}
# ... data={"id":${BOOK_150.ID},"title":"${BOOK_150.Title}","description":"${BOOK_150.Description}","pageCount":${BOOK_150.PageCount},"excerpt":"${BOOK_150.Excerpt}","publishDate":"${BOOK_150.PublishDate}"}
# ... headers=${HEADERS}
Log ${RESPOSTA.text}
Set Test Variable ${RESPOSTA}
Can I reproduce it with the fakeapi url you pasted? Would mind create a Pull Request with a failing test?
https://github.com/MarketSquare/robotframework-requests/pull/335