How to find the incoming data format (like json or xml) dynamically

Hi everyone,

I am passing the data from postman and I need to route the data based on the incoming data whether it is json or xml. Based on this, I have to do the other logics. So my issue was, how to find the incoming data format? For this I have tried some ways but those are not worked for me. Can you please anyone help me with this.
Thanks in advance.

You might want to look at the Binary Router snap to see if that might solve what you’re trying to do.

Hi @koryknick

Based on content-type only will route the data in Binary Router snap. But how to get that field, I am giving the incoming data from postman. I am not able to get that.
Please help me with this.

Hello @pjanapati,

If you specify the Content-Type header in the request, you should be able to access it within the SnapLogic Pipeline by using _CONTENT_TYPE.

e.g.

For more information please refer to [Passing Pipeline Arguments to Triggered Tasks].

Sample pipeline:
sl-comm-request-data-type_2023_04_26.slp (8.0 KB)

Let me know if this helps you.

BR,
Aleksandar.

Hi @AleksandarAngelevski

In your pipeline, from where you are providing the content-type field in binary router snap.
I am not able to get that. I am facing an error if I gave like you.

In postman I am giving the input data like below:
image
And the headers are:
image

Can you please suggest, if I did in a wrong way.
Thanks in advance.

Here is a sample pipeline using the Binary Router and the $[‘content-type’] binary header.
SimpleAPI_2023_04_26.slp (11.6 KB)

Here also is a screenshot of the JSON call:

image

I tested and this also works with application/xml as Content-Type and XML content in the body.