Robotic Process Automation (RPA)

 View Only
Expand all | Collapse all

HTTP request = OK @ Postman X HTTP request error (invalid token) @ IBM RPA Studio

  • 1.  HTTP request = OK @ Postman X HTTP request error (invalid token) @ IBM RPA Studio

    Posted Fri July 16, 2021 09:38 AM
    Hi all!

    When I test this HTTP request at Postman tool it runs perfectly, see the test below.

    But, when I test it on the IBM RPA Studio, it´s returning invalid token error:



    Here is the provisioning for the HTTP:


    Here is the code:

    defVar --name varURL_Envio_SMS --type String --value "http://srvvmeta01:8096/api/sms/send"
    defVar --name varDestinatario_Celular_Teste --type String --value 31999855622
    defVar --name varMensagem_Teste_SMS --type String --value "Teste API de envio de SMS da MGS, by Mauro Sérgio"

    httpRequest --verb "Post" --url "${varURL_Envio_SMS}" --formatter "Json" --source "{\r\n\"token\": \"b88f39f8306875fc87rtbcb60eb15adad54e\",\r\n\"mktUser\":\"mesaop\",\r\n\"to\":${varDestinatario_Celular_Teste},\r\n\"msg\":${varMensagem_Teste_SMS}\r\n}" --comment "Chamada HTTP para envio dos SMS" varSucesso_Chamada_EnvioSMS=success varResposta_EnvioSMS=value varStatus_Code_EnvioSMS=statusCode

    ------------------------------
    Mauro Sérgio
    ------------------------------


  • 2.  RE: HTTP request = OK @ Postman X HTTP request error (invalid token) @ IBM RPA Studio

    Posted Mon July 19, 2021 08:35 AM

    Hello!

    Maybe this JSON body has some missing quotation marks.
    I would suggest you print the JSON body (by using the logMessage command) in the output panel to check if every parameter is surrounded by them.



    ------------------------------
    Antonio Campos Junior-WDG
    ------------------------------



  • 3.  RE: HTTP request = OK @ Postman X HTTP request error (invalid token) @ IBM RPA Studio

    Posted Mon July 19, 2021 09:01 AM
    Hi Antonio!

    Your reading of the situation is right, there were some missing "" at the body.
    I´ve just stuffed them with some "" and it worked perfectly. The lesson learned is that both parameters at the right and left of : must be between "", when using the body instead of mapping.

    Here is the body after adding "":
    {

    "token":"b88f39f8306875fc87rtbcb60eb15adad54e",

    "mktUser": "mesaop",

    "to": "${varDestinatario_Celular_Teste}",

    "msg": "${varMensagem_Teste_SMS}"

    }

    Thank you very much and have a nice week.
    Best Regards.

    ------------------------------
    Mauro Sérgio
    ------------------------------