Json authentication request body contains a dollar sign

283 Views Asked by At

I'm writing an http post request to access an endpoint of an api responsible for user authentication, what happens is that the documentation from the api gives an example of body request that looks like this:

{
   "serviceName": "MobileLoginSP.login",
      "requestBody": {
           "NOMUSU": {
               "$": "USUARIOTESTE"
           },
           "INTERNO":{
              "$":"123456"
           },
          "KEEPCONNECTED": {
              "$": "S"
          }
      }
  }

I couldn't find anything online about that weird dollar sign in the body request, and in the code editor it throws this error Expected an identifier.dart(missing_identifier), I'm coding a flutter app.

2

There are 2 best solutions below

0
Ayush Yadav On

Dollar($) has a special significance in Dart for string interpolation. You can use ['$'] instead of ['$'] in order to hint that this Dollar sign is not a special char.

0
Ruchit On

you have to use '$' to recognize as String, you can read more about it here in official flutter documentation.