Question

How to construct a JSON object with a webhook

  • 20 February 2021
  • 2 replies
  • 17 views

I am trying to construct a webhook that can be consumed by an application. The basic idea is that I pass a variable to the webhook and it retrieves data and there is only a single object that is passed back.

 

I have been able to create it to look like this:

[

    {

        "barcode": "C000176",

        "assetid": "F01239",

        "description": "Dell Inc. - Latitude 7490",

        "type": "Office Equipment",

        "location": "Building 1"

    }

]

 

I need it to be presented like this:

    {

        "barcode": "C000176",

        "assetid": "F01239",

        "description": "Dell Inc. - Latitude 7490",

        "type": "Office Equipment",

        "location": "Building 1"

    }

 

I have been able to create a text file (JSON) that produces something like what I am looking for when I am on the desktop. The second I publish it to the server and try postman, I am getting an error (FME Data Streaming Service Failed to Complete).

 

In the below image the connected one produces the array with the [square brackets]. The _result of the JSONTemplator is perfect, but I haven't found a way to write it to a json file that produces the results desired in a webhook. The disconnected text file, creates the file correctly on my desktop, but gives the error when I publish it and try to call the API.

 

Capture


2 replies

Userlevel 5
Badge +29

When you're publishing to server, is it being published as a streaming service?

Also on your textFile writer, try setting the MIME Type to application/json

Screenshot 2021-02-22 075356

When you're publishing to server, is it being published as a streaming service?

Also on your textFile writer, try setting the MIME Type to application/json

Screenshot 2021-02-22 075356

It is being published as a data streaming service. I have it set to application/json. Including a few additional screenshots of the text output. Capture4Capture3Capture2

Reply