WEB Api

Hi All, 

I'm trying to pass JSON object in the startprocess but some how I'm not able to send all the attributes at one go 

Here is the sample JSON I'm passing 

{
"CompanyName": "Company",
"Category": "Information Technology",
"SubCategory": "COnsulting",
"Definition": "On Call",
"ShipToState": "AK",
"invoiceDetails": [
{
"InvoiceNumber": "3425638769",
"InvoiceDate": "1/28/2022",
"InvoiceValue": "400.00$",
"InvoiceDueDate": "2/22/2022",
"InvoiceBalance": "300.00$"

},
"InvoiceNumber": "3425638769",
"InvoiceDate": "1/28/2022",
"InvoiceValue": "400.00$",
"InvoiceDueDate": "2/22/2022",
"InvoiceBalance": "300.00$"

]
}

In the above JSON I was able to get all the individual attributes into the process model except the  Invoice details

Any help is much appreciated 

Thanks  

  Discussion posts and replies are publicly visible

Parents
  • That doesn't look like valid JSON to me - I think you need additional brackets around your second list of invoice numbers like this:

    {
      "CompanyName": "Company",
      "Category": "Information Technology",
      "SubCategory": "COnsulting",
      "Definition": "On Call",
      "ShipToState": "AK",
      "invoiceDetails": [
        {
          "InvoiceNumber": "3425638769",
          "InvoiceDate": "1/28/2022",
          "InvoiceValue": "400.00$",
          "InvoiceDueDate": "2/22/2022",
          "InvoiceBalance": "300.00$"
    
        },
        {
          "InvoiceNumber": "3425638769",
          "InvoiceDate": "1/28/2022",
          "InvoiceValue": "400.00$",
          "InvoiceDueDate": "2/22/2022",
          "InvoiceBalance": "300.00$"
        }
      ]
    }

    Can you update your request to include that valid JSON?

  • Hi Peter, Thank you for the Response ,but still I have no luck 

    Thank you

    Nanda

  • I think you'll have to provide more context for us to help you. Did you update your request to send valid JSON? What does your Web API look like? How is the process model set up? What troubleshooting steps have you tried? The more information you provide the faster we'll be able to suggest a solution.

  • Yea I have updated with the Valid JSON,and the web api looks like below 

    a!localVariables(
    a!startProcess(
    processModel: cons!LN_FDM_PM,
    processParameters: rule!LN_FDM_RULE_WEBAPI(
    httpRequest: a!fromJson(http!request.body)
    ),
    onSuccess: a!httpResponse(
    statusCode: 200,
    headers: {
    a!httpHeader(
    name: "Content-Type",
    value: "application/json"
    )
    },
    body: index(fv!processInfo.pv, "requestId", null)

    ),
    onError: a!httpResponse(
    statusCode: 500,
    headers: {
    a!httpHeader(
    name: "Content-Type",
    value: "application/json"
    )
    },
    body: a!toJson(
    {
    error: "There was an error starting the process"
    }
    )
    )
    )
    )

Reply
  • Yea I have updated with the Valid JSON,and the web api looks like below 

    a!localVariables(
    a!startProcess(
    processModel: cons!LN_FDM_PM,
    processParameters: rule!LN_FDM_RULE_WEBAPI(
    httpRequest: a!fromJson(http!request.body)
    ),
    onSuccess: a!httpResponse(
    statusCode: 200,
    headers: {
    a!httpHeader(
    name: "Content-Type",
    value: "application/json"
    )
    },
    body: index(fv!processInfo.pv, "requestId", null)

    ),
    onError: a!httpResponse(
    statusCode: 500,
    headers: {
    a!httpHeader(
    name: "Content-Type",
    value: "application/json"
    )
    },
    body: a!toJson(
    {
    error: "There was an error starting the process"
    }
    )
    )
    )
    )

Children