I am trying to use Ionic Native HTTP but I can not send a array JSON. my code example:
let body = {“DivipolaModel”: [ ]}
let headers = {“Content-Type”:“application/json”,
token:123}
this.http.post(‘MyURL’,body,headers)
this response: error 500
I am trying to use Ionic Native HTTP but I can not send a array JSON. my code example:
let body = {“DivipolaModel”: [ ]}
let headers = {“Content-Type”:“application/json”,
token:123}
this.http.post(‘MyURL’,body,headers)
this response: error 500
try
let body = { DivipolaModel : [ ]} // without quotes
or try
const params = { DivipolaModel : [ ]}
let body = new HttpParams();
for (let k in params) {
body = body.set(k, params[k]);
}
const reqOpts = {
headers: new HttpHeaders({ "Content-Type": "application/json",
token: 123 })
};
this.http.post('MyURL', body, reqOpts);
how use
HttpParams()
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
Then Ctrl+C and Ctrl+V to my code
responce error 500.
print console.err:
[app-scripts] {“status”:500,“url”:“http://dependenciajudicial.prozesslaw.com/DependenciaJudicialApi/Usuario/ActualizarUsuario",“headers”:{“okhttp-response-source”:"NETWORK
[app-scripts] 500”,“cache-control”:“no-cache”,“pragma”:“no-cache”,“content-type”:“application/json;
[app-scripts] charset=utf-8”,“server”:“Microsoft-IIS/7.5”,“date”:“Tue, 15 Jan 2019 22:09:43
[app-scripts] GMT”,“content-length”:“20”,“expires”:"-1",“x-powered-by”:“ASP.NET”,“x-aspnet-version”:“4.0.30319”,“okhttp-selected-protocol”:“http/1.1”},“error”:"{“Message”:“Error.”}"}
que asquito ese servidor
The server POST request is tested and working?