Robotic Process Automation (RPA)

 View Only
  • 1.  HTTP Request method GET

    Posted Mon June 13, 2022 07:05 AM
    Hi,

    I have an issue when I try to use HTTP Request.

    From the studio I receive:
    Response: Something bad happened. Check your request and try again !!
    Status: 500
    Reason Phrase: Internal Server Error
    Header: [Server=nginx/1.19.6, Date=Mon, 13 Jun 2022 10:58:46 GMT, Transfer-Encoding=chunked, Connection=keep-alive]
    Message: [Content-Type=text/plain]

    When I try from SOAP UI result is:


    The endpoint is: http://api.polycomp.bg/service/data/v1/vendors/test
    and the studio code is:

    defVar --name success --type Boolean
    defVar --name response --type String
    defVar --name status --type Numeric
    defVar --name reasonPhrase --type String
    defVar --name header --type StringDictionary --innertype String
    defVar --name message --type StringDictionary --innertype String
    httpRequest --verb "Get" --url "http://api.polycomp.bg/service/data/v1/vendors/test" success=success response=value status=statusCode reasonPhrase=reasonPhrase header=headers message=contentHeaders
    logMessage --message "Success: ${success}\r\n\r\nResponse: ${response}\r\n\r\nStatus: ${status}\r\n\r\nReason Phrase: ${reasonPhrase}\r\n\r\nHeader: ${header}\r\n\r\nMessage: ${message}" --type "Info"

    Could you support me where I am wrong?

    Best regards,

    ------------------------------
    Stanislav Terziev
    ------------------------------


  • 2.  RE: HTTP Request method GET

    Posted Mon June 27, 2022 03:36 PM
    Hello Stanislav!

    I got your issue covered!
    What you are experiencing has to do with the default  Accept header sent by the HTTP Request command of IBM RPA (cf screenshot below):
    The website your try to query returns an application/xml payload. By default, your RPA client specifies that it can only process application/json , application/bson or text/xml .
    As the resource you are trying access isn't any of those types, the server returns a generic 500 error.
    (Trivia: if the server was fully compliant with the HTTP norm, it should have been an 406 error ; but that's not our problem :) )

    If you want to overwrite this default header in RPA, you can pass a String Dictionary with a key-value including your list of accepted MIME types to the HTTP Request command. If you don't want to bother finding each time the MIME type returned by your server, you can use the more generic "accept all" header :   Accept: */* 

    Here is your initial code modified : 

    defVar --name success --type Boolean
    defVar --name response --type String
    defVar --name status --type Numeric
    defVar --name reasonPhrase --type String
    defVar --name header --type StringDictionary --innertype String
    defVar --name message --type StringDictionary --innertype String
    defVar --name reqHeaders --type StringDictionary --innertype String
    strDictAdd --key Accept --value "*/*" --dictionary ${reqHeaders}
    httpRequest --verb "Get" --url "http://api.polycomp.bg/service/data/v1/vendors/test" --headers ${reqHeaders} success=success response=value status=statusCode reasonPhrase=reasonPhrase header=headers message=contentHeaders
    logMessage --message "Success: ${success}\r\nResponse: ${response}\r\nStatus: ${status}\r\nReason Phrase: ${reasonPhrase}\r\nHeader: ${header}\r\nMessage: ${message}\r\n---" --type "Info"

    I hope this will unblock you!

    Regards,



    ------------------------------
    Pierre Daniel
    ------------------------------



  • 3.  RE: HTTP Request method GET

    Posted Tue June 28, 2022 02:14 AM
    Dear Pierre,

    Thank you for your appreciated support.
    Your solution solved the issue and unblocked me.
    The result is:

    Success: True
    Status: 200
    Reason Phrase: OK

    Best regards,
    Stanislav

    ------------------------------
    Stanislav Terziev
    ------------------------------