I'm trying to call a password change method from an API. A token is used for authentication. The parameters that the method expects are:
I tried to make a POST using the code:
but I receive the following message:
ResponseError. Reason: Bad Request, Response: {"Message":"The request is invalid.","ModelState":{"model.OldPassword":["The Current password field is required."],"model.NewPassword":["The New password field is required."]}}
and Log is: [{"OldPassword":"Parola_01","NewPassword":"Parola_02","ConfirmPassword":"Parola_02"}]
Can you help me with an idea?
B4X:
{
"OldPassword": "sample string 1",
"NewPassword": "sample string 2",
"ConfirmPassword": "sample string 3"
}
I tried to make a POST using the code:
B4X:
Dim j As HttpJob
j.Initialize("",Me)
Dim values As Map
values.Initialize
values.Put("OldPassword","Parola_01")
values.Put("NewPassword","Parola_02")
values.Put("ConfirmPassword","Parola_02")
Dim JsonList As List
JsonList.Initialize
JsonList.add(values)
Dim JSONGenerator As JSONGenerator
JSONGenerator.Initialize2(JsonList)
Log(JSONGenerator.ToString())
j.PostString("http://servername.ro/api/account/changepassword",JSONGenerator.ToString())
j.GetRequest.SetHeader("Authorization","Bearer " & Main.Token)
but I receive the following message:
ResponseError. Reason: Bad Request, Response: {"Message":"The request is invalid.","ModelState":{"model.OldPassword":["The Current password field is required."],"model.NewPassword":["The New password field is required."]}}
and Log is: [{"OldPassword":"Parola_01","NewPassword":"Parola_02","ConfirmPassword":"Parola_02"}]
Can you help me with an idea?