The error message is AttributeError: 'str' object has no attribute 'items' for Post Request

703 views
Skip to first unread message

Prakash Samal

unread,
Oct 22, 2021, 4:09:03 AM10/22/21
to robotframework-users
Hi,
PFA below code:
*** Settings ***
Library RequestsLibrary
Library JSONLibrary
Library Collections
*** Variables ***
${Base_Url}= http://restapi.demoqa.com/customer

*** Test Cases ***
Create new resource
create session adddata ${Base_Url}
${body}= create dictionary First_Name=Prakash Last_Name=Samal DOB=01/05/1993
${header}= create dictionary Content-Type=pplication/json
${response}= POST On Session adddata /register data=${body} headers= ${header}
log to console ${response.status_code}
log to console ${response.content}

Note: I am getting an AttributeError: 'str' object has no attribute 'items
Please let me know what needs to be done?

Regards,
Prakash

Craig Despeaux

unread,
Oct 22, 2021, 10:47:45 AM10/22/21
to robotframework-users
Don't know if this is what's causing your problem, but ${header} is missing the a in application/json.

I don't really see another issue based on what you've provided.

Craig

Craig Despeaux

unread,
Oct 22, 2021, 11:17:21 AM10/22/21
to robotframework-users
Another thought..  perhaps you should be using json= versus data= since your headers indicate you're passing JSON.

Craig

Reply all
Reply to author
Forward
0 new messages