Rest Service Call using httpWrite function

Hi, 

I am trying to call Rest Service, post method using httpWrite function. I am able to get call end point, using smart service but it doesn't work with httpWrite function.

This service returns JSON response which i am supposed to capture.

Any pointers will be great help.

Code:-

load(
local!count: bind(
get: null,
set: a!httpWrite(
url: "XX.XX.XX:9090/.../getUnpaidFoodInvoicesByUnit",
method: "POST",
headers: {},
body: _
)
),
a!formLayout(
firstColumnContents: {
a!textField(
label: "request",
value: local!count,
readOnly: true
),
a!buttonLayout(
secondaryButtons: {
a!buttonWidget(
label: "start",
value: a!toJson(
{
"clientId": "FRA501",
"invoiceType": "Food"
}
),
saveInto: {
local!count
}
)
}
)
}
)
)

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer
    a!httpwrite() returns a writer function and will not return a result. (docs.appian.com/.../fnc_connector_http_a_httpwrite.html)

    httppostwithresponse() from the shared component "Send HTTP Request Plug-in" should help you out. forum.appian.com/.../summary
  • Thanks Josh,
    I am using tojason method to make request body but getting Type value error.

    Expression evaluation error at function 'httppostwithresponse' [line 13]: Error evaluating function 'httppostwithresponse' : The passed parameter(s) are of the wrong type. Received the type com.appiancorp.common.xml.JaxbConversionException: JAXB was not able to produce a value for typed value TypedValue[it=94,v={TypedValue[it=3,v=clientId]=TypedValue[it=3,v=FRA5001939], TypedValue[it=3,v=invoiceType]=TypedValue[it=3,v=Domino's Food]}] as java class java.lang.Long.

     

    Modified code:

    load(
    local!requestBody: a!toJson(value:{ "clientId":"FRA5001939", "invoiceType":"Domino's Food"}),
    httppostwithresponse(
    endpoint: "http://XX.XX.XX.XX:9090/ws/rest/OSA_API/getUnpaidFoodInvoicesByUnit",
    paramNames: {},
    paramValues: {},
    headerNames: {},
    headerValues: {},
    user: null,
    password: null,
    domain: null,
    timeout: "60",
    body: local!requestBody
    )

    )

Reply
  • Thanks Josh,
    I am using tojason method to make request body but getting Type value error.

    Expression evaluation error at function 'httppostwithresponse' [line 13]: Error evaluating function 'httppostwithresponse' : The passed parameter(s) are of the wrong type. Received the type com.appiancorp.common.xml.JaxbConversionException: JAXB was not able to produce a value for typed value TypedValue[it=94,v={TypedValue[it=3,v=clientId]=TypedValue[it=3,v=FRA5001939], TypedValue[it=3,v=invoiceType]=TypedValue[it=3,v=Domino's Food]}] as java class java.lang.Long.

     

    Modified code:

    load(
    local!requestBody: a!toJson(value:{ "clientId":"FRA5001939", "invoiceType":"Domino's Food"}),
    httppostwithresponse(
    endpoint: "http://XX.XX.XX.XX:9090/ws/rest/OSA_API/getUnpaidFoodInvoicesByUnit",
    paramNames: {},
    paramValues: {},
    headerNames: {},
    headerValues: {},
    user: null,
    password: null,
    domain: null,
    timeout: "60",
    body: local!requestBody
    )

    )

Children