I have a project where I am trying to interact with a REST API, but I’m not well versed at all with how REST works in or out of UiPath Studio. I have downloaded the UiPath.WebAPI.Activities and am trying to make a call following the API documentation at this link: https://docs.labs.gaincapital.com/#HTTP%20Services/LogOn.htm
It’s not clear to me at all where in the activity definition I’m supposed to put the information requested to build the request body as defined in the documentation. I have my own UserName, Password, and AppKey, but I’m at a loss as to how to communicate them to get a session token returned to me.
Now you can store the request body in a notepad and then reading the same notepad (text file) using Read Text File Activity and storing the result in string variable and pass that string variable in that body section.
Have you tried wrapping the contents of json body in single quotes instead of using double double-quotes
“{‘Password’:‘openthedoor’,‘AppVersion’:‘1’,‘AppComments’:‘’,‘UserName’:‘DM1234’,‘AppKey’:‘ABC’}”
Also the change you made from application/xml to application/json is correct
I would say it is just matter of incorrect characters.
Take request body, pastes it into note, use ctrl + H (replace) and replace double quote (") to single quote-apostrophe (ascii decimal code is 39) an paste it into expression editor.
Forum interface is changing character to closing/opening single quotation mark
And below is the body string:
"{ 'Password ': 'openthedoor ', 'AppVersion ': '1 ', 'AppComments ': ’ ', 'UserName ': 'DM123456 ', 'AppKey ': 'ABC '} "
I tried it with this and the error I got was “{"AdditionalInfo":null,"StatusCode":0,"HttpStatus":401,"ErrorMessage":"Sorry, your login has failed|This is because your login credentials do not match our records.","ErrorCode":4010}”
I know it ended in error, but i dont have the valid creds so it was expected. Atleast it failed with different error right?
I have attached the workflow too for your reference. apidemo.zip (2.5 KB)
Please try it with by replacing your creds.