jsonapiflutterdartjsonresponse

Not getting proper api resonse in flutter


Getting the below issue when I pass the value in variable in json.encode not getting the excepted response, but I when pass the value without variable getting proper response I tried using map and different headers not able to get the exact issue.

  1. Not working

    String getvalue = “response-value”; var _body = json.encode({"context": getvalue});

    var res = await http.post(link, headers: { "Content-Type": "application/json", }, body: _body );

  2. working

    var _body = json.encode({ "responseValue”: "response-value" });

    var res = await http.post(link, headers: { "Content-Type": "application/json", }, body: _body );


Solution

  • It is solved, there was issue an issue in the backend api which got solved know.