Release Automation

Expand all | Collapse all

Rest Operation -  Usage

Jump to Best Answer
  • 1.  Rest Operation -  Usage

    Posted 09-19-2016 04:21 PM

    HI Guys, I need to obtain a token from a security web page:

     

     

    Reference for https://aest-segu56/ERPMWebService/JSON/V2/AuthService.svc/DoLogin2

    Login and create an authentication token returned as a JSON object

    Url: https://aest-segu56/ERPMWebService/JSON/V2/AuthService.svc/DoLogin2

    HTTP Method: POST

    Message directionFormatBody
    RequestXmlExample,Schema
    RequestJsonExample
    ResponseXmlExample,Schema
    ResponseJsonExample

    The following is an example request Xml body:

    <LoginInfo xmlns="http://schemas.datacontract.org/2004/07/RouletteAppService_WCF">   <Authenticator>String content</Authenticator>   <LoginType>Unknown</LoginType>   <MFATokenCode>String content</MFATokenCode>   <OnBehalfOfUser>     <Username>String content</Username>   </OnBehalfOfUser>   <Password>String content</Password>   <SAMLAudience>String content</SAMLAudience>   <SAMLCert>String content</SAMLCert>   <SAMLDomainGroups>String content</SAMLDomainGroups>   <SAMLDomainUsers>String content</SAMLDomainUsers>   <SAMLIssuer>String content</SAMLIssuer>   <SAMLResponse>String content</SAMLResponse>   <SAMLRoles>String content</SAMLRoles>   <SAMLSubject>String content</SAMLSubject>   <Username>String content</Username> </LoginInfo>

     

    The data to send is the following:

               {

          "LoginType":1,

          "Password":"Password-de-usuario",

          "Username":"usuario"

    }

     

     

    I tried using the REST OPERATION ACTION ( I don't understand where to insert the parameters). I got 400 Bad Request Error.

     

     

     

    Did anyone use this before?

     

     

    Thanks.



  • 2.  Re: Rest Operation -  Usage

    Posted 09-20-2016 01:10 AM

    Did you try to set the data in the body field ?

    Below an example how to use REST call in RA to run deployment



  • 3.  Re: Rest Operation -  Usage

    Posted 09-20-2016 04:02 AM

    yes, try putting your "data to send" section in to the body of the rest action, that should do it



  • 4.  Re: Rest Operation -  Usage

    Posted 09-21-2016 04:18 PM

    Michael: I tried the way you suggested me but I get a "raw format error":

     

     

     

     

     

    Inputs:

    URIhttps://aest-segu56/ERPMWebService/JSON/V2/AuthService.svc/DoLogin2
    Rest VerbPOST
    Parametersnull
    Http Headersnull
    Body{"LoginType":"1","Password":"Teco2016","Username":"z001250"}
    Response File Pathnull
    Check Response Codefalse
    Include Http Headers In Responsefalse
    Connection Timeout (seconds)60
    Read Timeout (seconds)0
    Authentication MethodNONE
    Domainnull
    Realmnull
    User Namenull
    Password*******
    Use Preemptive Authenticationfalse
    Expected Codenull
    Proxy Server Namenull
    Proxy Server Portnull

    Outputs:

    Response As String<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Request Error</title> <style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active { color: #336699; font-weight: bold; text-decoration: underline; } .heading1 { background-color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding: 5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse; border-spacing: 0px; font-family: Verdana;} table th { border-right: 2px white solid; border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td { border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}</style> </head> <body> <div id="content"> <p class="heading1">Request Error</p> <p xmlns="">The server encountered an error processing the request. Please see the <a rel="help-page" href="https://aest-segu56/ERPMWebService/JSON/V2/AuthService.svc/help">service help page</a> for constructing valid requests to the service. The exception message is 'The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml', 'Json'. This can be because a WebContentTypeMapper has not been configured on the binding. See the documentation of WebContentTypeMapper for more details.'. See server logs for more details. The exception stack trace is: </p> <p> at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.CompositeDispatchFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&amp; rpc) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&amp; rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp; rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp; rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp; rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp; rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp; rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</p> </div> </body> </html>
    Response Headers As StringContent-Length: 3646 Content-Type: text/html Server: Microsoft-IIS/8.0 X-Powered-By: ASP.NET X-Frame-Options: SAMEORIGIN Date: Wed, 21 Sep 2016 20:11:16 GMT
    HTTP Response Code400

     

     

    Thanks.



  • 5.  Re: Rest Operation -  Usage

    Broadcom Employee
    Posted 09-21-2016 04:28 PM

    Based on that message you might have to add the following to the http headers field: Content-Type: application/json



  • 6.  Re: Rest Operation -  Usage
    Best Answer

    Posted 09-21-2016 05:05 PM

    Thanks Gregg. It worked.

     

     

    Thanks for your help on this!