How to send Array of String in Request Params for REST API

How to send Array of String in Request Params for REST API

  

Hi,

My Request Params for REST API are:

{
        "UserId":"assif@lapis.com",
         "countries": [ "3", "54", "203" ],
         "products": ["1","3","7"]
}

While I consume API, the Structure for Request is generated as below:

I provided the Text List While calling the API, but the API request is going as below:

countries: {List: ["1","21","22"]}

What I actually want it to be:

  "countries": [ "3", "54", "203" ]


Thanks,

Assif


Hi Assif,

I just tried, and I can't reproduce your problem. In the Integration Logging, I see this:

{"UserId":"Kilian","countries":["1","2","3"],"products":["A","B","C"]}

Note I created the REST service with the same request JSON as you have above. Where did you see the "List"? In the Integration Logging? Someplace else?

Kilian Hekhuis wrote:

Hi Assif,

I just tried, and I can't reproduce your problem. In the Integration Logging, I see this:

{"UserId":"Kilian","countries":["1","2","3"],"products":["A","B","C"]}

Note I created the REST service with the same request JSON as you have above. Where did you see the "List"? In the Integration Logging? Someplace else?

I was inspecting under Network tab in Browser & there I check the request param sent  as:

countries: {List: ["1","21","22"]}


Solution

Hi Assif,

I'm a bit lost there. You are talking about the browser, while REST communication is always handled by the server, so unless you're calling from mobile, the browser can't see it. Also, if you are on Mobile, what you're seeing is the communicaton between the Mobile App and the server, not between the server and the REST end-point. Please follow these instrutions to enable logging of the REST traffic and check the log what is actually sent.

Solution

Kilian Hekhuis wrote:

Hi Assif,

I'm a bit lost there. You are talking about the browser, while REST communication is always handled by the server, so unless you're calling from mobile, the browser can't see it. Also, if you are on Mobile, what you're seeing is the communicaton between the Mobile App and the server, not between the server and the REST end-point. Please follow these instrutions to enable logging of the REST traffic and check the log what is actually sent.

Wooo,

Thanks. It saved lot of my time.

It was showing inCorrect in Browser but Actually it was working fine & going Correct.


Thanks for the feedback. Happy coding!