Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Words pt-br with accents is causing 400 Bad Request on the new Post/Put On Session #334

Open
mayribeirofernandes opened this issue May 31, 2021 · 4 comments
Labels

Comments

@mayribeirofernandes
Copy link

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?

image

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

@mayribeirofernandes mayribeirofernandes changed the title Words pt-br with accents is causing 40 Bad Request Words pt-br with accents is causing 400 Bad Request on the new Post/Put On Session May 31, 2021
@lucagiove
Copy link
Member

That's most probably because you're using the data= parameter instead of json= try to swap those parameters.

@mayribeirofernandes
Copy link
Author

@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}

@lucagiove
Copy link
Member

Can I reproduce it with the fakeapi url you pasted?
Would mind create a Pull Request with a failing test?

@lucagiove lucagiove reopened this Jun 11, 2021
@lucagiove lucagiove added the bug label Jun 11, 2021
@mayribeirofernandes
Copy link
Author

#335

@lucagiove lucagiove moved this to To do in Next Version May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: To do
Development

No branches or pull requests

2 participants