Invalid JSON Payload

I’ve implemnted a javascript application that is using the oDataDispatcher in a delphi server to access a DataTable.
The read looks fine and i get my data but when i try to update a record i get an “invalid json payload” exception.
I’ve set the method for update to PUT.

At the moment i don’t know what format the oData expects;

my json looks something like:

‘{“numeagent”:“AGENT IMPLICIT33”,“id”:“ProiecteWEB.model.Agenti-1”}’

and i also tried like this

‘{“d”:{“numeagent”:“AGENT IMPLICIT33”,“id”:“ProiecteWEB.model.Agenti-1”}}’

But this throw the missing term exception.

I would like to know what the oData expects when the data comes back(ex. does it want all the fields, or the primary key, or the structure that i pulled at the begining? )

Thanks

try to use something like

PUT http://192.168.116.1:8100/odata/Territories(117434)?$format=json HTTP/1.1
Authorization: Basic bWU6bWU=
Host: 192.168.116.1:8100
Content-Length: 242
Expect: 100-continue
{
    "d" :     {
        "__metadata" :         {
            "uri" : "http:\/\/192.168.116.1:8100\/odata\/Territories(117434)",
            "type" : "ODataService.Territories"
        },
        "ID" : "117434",
        "Description" : "UPDATE - Test row - 2",
        "RegionID" : "1"
    }
}
POST http://192.168.116.1:8100/odata/Territories?$format=json HTTP/1.1
Authorization: Basic bWU6bWU=
Host: 192.168.116.1:8100
Content-Length: 224
Expect: 100-continue
{
    "d" :     {
        "__metadata" :         {
            "uri" : "http:\/\/192.168.116.1:8100\/odata\/Territories(5555)",
            "type" : "ODataService.Territories"
        },
        "ID" : "506899",
        "Description" : "Dummy",
        "RegionID" : "1"
    }
}

I tried sending the data in this format and it’s getting into another problem.
at:
for i := 0 to lNewFields.Count -1 do begin
n := lNewFields.IndexOf(aRec^.lQuery.Keys.Names[i]);

The keys array is empty.

The JSON i send in the “d” property looks like this:

{
“__metadata”:
{
“uri”:“http://192.168.77.16:8099/odataProiecte/tblAgenti({IMP})”,
“type”:“ODataService.Proiecte”
},
“CODAGENT”:“{IMP}”,
“NUMEAGENT”:“Test oData”
}

Is there anything else i am missing?

can you create a simple testcase, pls?
you can attach it here or send directly to support@