Web HTTP/HTML: how to record a RESTrequest with Basic authentication

Hi all, 

I have to make a script for a single REST web service, with all parameters in the endpoint and a Basic authentication in which you have to specify the domain. I've try to open a Web HTTP-HTML new script, and click on "Design -> Insert in Script -> REST API" option, so I've insert the URL in the form and the fuction web_rest will made; after I've insert the web_set_user() function and I've also specify the credential on Runtime Settings (under "Internet Protocol -> Proxy -> Authentication" but when I run the script the error below appeared: 

HTTP Status-Code=401 (Unauthorized) for "https://...."

Can anyone explain me what's the procedure to record a REST web service? Thank you very much. 

Below an extract from the script in Web HTTP-HTML protocol: 

web_rest("web_service_1",
        "URL=http://sgssw0.syssede.systest.sanpaoloimi.com:24064/mxomniaweb/mxrest/MXOMNINSTANCE?SERVICE_ID=&LISTEN_HOST=saxstp526",
        "Method=GET",
        "EncType=raw",
        "Snapshot=t296930.inf",
        LAST);

  • Hi, 

    Thanks for the information. 

    Could you please specify the version that you are using? 

    In the link below you will find useful information about how to create a script for a REST API (version 12.56-57)

    https://admhelp.microfocus.com/lr/en/12.56-12.57/help/WebHelp/Content/VuGen/t_RESTAPI.htm

    Regards,

     

     

  • Hi Jorge, 

    thanks for suggestions. I've just read that article in the official documentation, but the methods explained can't find any solution on the problem, maybe caused by the application/service itself. I resolve the matter with a simple web_custom_request() function on Web HTTP-HTML protocol, but my intention was that to write something closely related to the problem. I will make some other researches on the web and I'll write if I found something useful. 

    Thanks again,

    Lorenzo

  • Verified Answer

    Hi all, 

    I've found a possible solution to my doubt: the problem was about the Basic authentication in Web HTTP-HTML recording for web services. Since the upload of URL or responses from "Design -> Insert in Script -> REST API" option doesn't work, I've load the endpoint and the message in a SoapUI project, so I've add an authentication (in Basic mode, you can choose many options of web authentication) and run a request: I've copied the request authentication header and put it in a web_add_header() function. 

        web_add_header("Authorization", "Basic GETDRDNBEY==");

    Naturally this step will be set before the web_custom_request() or web_url() functions, so to add an authentication header to all request messages. Now the script goes well. 

    Thanks for the collaboration, 

    Lorenzo