Home > Software design >  Post request returns 400 Bad Request in RobotFramework
Post request returns 400 Bad Request in RobotFramework

Time:02-17

I've been using a RobotFramework for sending a POST request My code is the following :

*** Settings ***
Library  RequestsLibrary
Library  JSONLibrary
Library  Collections


*** Variables ***
${API_Base_Endpoint}    http://thetestingworldapi.com/




*** Test Cases ***
Post_Req_Test
    Create Session          AddData            ${API_Base_Endpoint}
    ${body}=                create dictionary   first_name=Tester1  middle_name=NAN  last_name=Tester2  date_of_birth=01/01/1999
    LOG TO CONSOLE          ${body}
    ${header}=              create dictionary   Content-Type=application/json
    ${response}=            post on session     AddData    api/studentsDetails     data=${body}  headers=${header}

But from some reason I'm getting a "HTTPError: 400 Client Error: Bad Request for url: http://thetestingworldapi.com/api/studentsDetails"

I've tried to send same request via Postman , and it works with no issues.

Any ideas what may go wrong ?

CodePudding user response:

With the help of @MatthewKing I was referenced to this solution Worked for me

  • Related