How to use ionic native HTTP send array JSON

#1

I am trying to use Ionic Native HTTP but I can not send a array JSON. my code example:

let body = {“DivipolaModel”:}
headers = {token:“token”}
this.http.post(‘MyURL’,body,headers)

this JSON send:
{“DivipolaModel”:}

#2

What device are you testing this on? Are any errors thrown when you remote debug it?

#3

I am testing in the emulator android studio with api 22.

I have not tried remote debug but I printed console.

This is the output on my console.
console.error: {“Message”:“Error.”}
console.error: headers 500

#4

if the response code is 500 then it’s a problem ocurring in the server side.

To send a JSON you just have to make an object:

{
field1: value1,
field2: value2
}
#5

you’re right, but To send a JSON I just have to make an array.

#6
[
{
field1: value1,
field2: value2
},
{
field1: value1,
field2: value2
},
{
field1: value1,
field2: value2
},
etc
]
#7

I am using typescript but send.
this example:
let body = {DivipolaModel:
[{
field1: value1,
field2: value2
},
{
field1: value1,
field2: value2
},
{
field1: value1,
field2: value2
}
] }