API test with robot framework

Hi everyone

I’m trying to test API using robot framework, I tried with:
${access_token}= evaluate $resp.json().get(‘access_token’)

But I got error:
Evaluating expression ‘$resp.json().get(“access_token”)’ failed: JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Any idea how to solve this problem ?

Thanks !

A few ideas to try:

${access_token}=     evaluate      ${resp}.json().get(‘access_token’)

or

${access_token}=     Get From Dictionary     ${resp.json()}     access_token

or

${access_token}=         Convert To String       ${resp.json()['access_token']}

Since it’s a JSONDecodeError, it looks to me that while $resp is indeed a Response instance (since it has a json() method that can be called on it), decoding fails because there’s nothing to decode; the Response.text is most likely empty.

Try setting a breakpoint and taking a look at $resp or log the $resp.text.