Hello,
I’m trying to perform a post request and then run a cumulus keyword to validate if the rest api created everything correct on the database.
If I run the test without creating a new session, this cumulus keyword pass. However when I create a session and then try to perform a Salesforce query using the Cumulus Salesforce insert I receive the following error:
“TypeError: You must provide login information or an instance and token”
Please have a look to the following code:
*** Settings ***
Documentation
Resource …/…/…/resources/Xxxx.robot
Resource …/Setup.robot
Library …/…/…/resources/LandingPageObject.py
Library cumulusci.robotframework.PageObjects
Library DateTime
Library RequestsLibrary
*** Variables ***
Response Codes
${CODE_OK} = 200
${CODE_CREATED} = 201
${CODE_BAD_REQUEST} = 400
${CODE_UNAUTHORIZED} = 401
${CODE_NOT_FOUND} = 404
${CODE_SERVER_ERROR} = 500
Methods
${GET} = Get Request
${POST} = Post Request
${PUT} = Put Request
Token
${ACCESS_TOKEN} = Starting a variable
Body
${REQ_BODY} = {“items”: [{“rewardId”: “a0z8a00000F6m2uAAB”,“quantity”: “1”}]}
URLs
${REQ_BASE_URL} = /services/apexrest/Xxxx/v1/members/a0e8a00000H0QJfAAN/redemptions
Responses
${SUCCESS} = Variable to be compered with response
*** Keywords ***
Get Salesforce Org Access
${orginfo}= Get Org Info
${ACCESS_TOKEN}= Pop From Dictionary ${orginfo} access_token
${INSTANCE_URL}= Pop From Dictionary ${orginfo} instance_url
Set Global Variable ${ACCESS_TOKEN} ${ACCESS_TOKEN}
Set Global Variable ${INSTANCE_URL} ${INSTANCE_URL}
Check For Access Token
[Arguments] ${access_token}
Run Keyword If ‘${access_token}’ == ‘Starting a variable’
… Get Salesforce Org Access
Create Request
[Arguments] ${method} ${access_token} ${base_url} ${body}
Check For Access Token ${access_token}
Create Session POST ${INSTANCE_URL}
${header}= Create Dictionary Authorization=Bearer ${ACCESS_TOKEN} Content-Type=application/json
${response}= Run Keyword ${method} POST
… ${base_url} data=${body} headers=${header}
Set Suite Variable ${response} ${response}
Post Redemption
Create Request ${POST} ${ACCESS_TOKEN} ${REQ_BASE_URL} ${REQ_BODY}
*** Test Cases ***
- POST - SUCCESS
Post Redemption
${Account}= API Create Account