Guy’s, I’ve got a problem with a POST in robot.
I’m sending a GET in a URL , this URL I get a Token and put it inside a variable to use the variable in my POST sending inside form-data.
I need to get a token before sending the POST using form-data.
but the response of the POST , always is error because the token.
This token needs to be kept in the same session to work.
How do I do? It’s correct the sending form-data or doesn’t is it the same session?
My code:
Create Session StartAPI ${URL_LOGINSHOW} verify=true
${response} Get ${URL_LOGINSHOW}
${response_body} Set Variable ${response.content} # Store the response body in a variable
${response_str} Convert To String ${response_body}
${value} Get Lines Containing String ${response_str} dynamic-csrf-token
${csrf_token} Get Substring ${value} 70 250
Log ${csrf_token} # Print the extracted value
Set Global Variable ${csrf_token} **//here I got the token**
Create Session StartAPI ${URL_SUBMITREGISTRATION} verify=true
${HEADERS}= Create Dictionary
#… Content-Type=${CONTENT_TYPE}
#… User-Agent=RobotFramework
#… Accept=/
… Authorization=Basic ${auth_data}
${payload} Create Dictionary
… dwfrm_profile_customer_firstname Newton
… dwfrm_profile_customer_lastname Newton
… dwfrm_profile_customer_cpf 096.344.033-11
… dwfrm_profile_customer_birthdate 13/04/1992
… dwfrm_profile_customer_email newton.test@gmail.com
… dwfrm_profile_customer_phone (81) 99291-8155
… dwfrm_profile_login_password Teste@123
… dwfrm_profile_login_passwordconfirm Teste@123
… csrf_token ${csrf_token} //here I use the token
${RESPONSE}= POST On Session StartAPI ${URL_SUBMITREGISTRATION} data={${payload}} headers=${HEADERS} expected_status=Anything
Log ${RESPONSE.json()}