0

I have the following JSON

{"name":"tester1","type":"frontend"}
{"name":"tester2","type":"midlleware"}
{"name":"tester3","type":"backend"}

When I paste the above into Postman with an application/JSON, only the 1st row/JSON will be passed to the function because of the lack of commas between each row. Note, I cannot change the incoming JSON format nor the Content-Type (application/JSON). Also note this is a valid multipart JSON See here

My API method is as follows:

public async Task<HttpResponseMessage> ProcessJson([FromBody] string _incomingJSON)

Note: I can change my signature ([FromBody] string _incomingJSON)

_incomingJSON is null if I use application/JSON but populated if I use text/plain (which I can't use)

Is there any way I can handle this format with application/JSON and not get _incomingJSON as null?

Thanks in advance

  • You should be able to get the raw POST data as a stream using [Getting raw POST data from Web API method](https://stackoverflow.com/q/13226817/3744182) and then deserialize as shown in [Line delimited json serializing and de-serializing](https://stackoverflow.com/q/29729063/3744182). – dbc Dec 11 '20 at 15:50
  • Can you add any other example endpoint where we can try this ? – PDHide Dec 12 '20 at 15:20

1 Answers1

-1

You should send with Postman in 3 rows like this:

as you see in the Postman picture

Salah
  • 64
  • 7
  • thanks, @salah, but I can't send 3 separate rows. the JSON comes in a bulk JSON input. I'm using Postman on;y for test purposes, the actual Post will come from an external server – deepfriedprune Dec 11 '20 at 17:45
  • You can get the bulk JSON and split it into an array of jsons – Salah Dec 22 '20 at 10:10