WinJS OData JSON
Asked Answered
B

1

0

try to send data to my database by web service an get this error:

Primitive values of type 'Edm.Decimal' and 'Edm.Int64' must be quoted in the payload. Make sure the value is quoted

here is my code:

var newEntry = {
        datum: entryDate,
        monat: parseFloat(entryMonth),
        taetigkeit: document.getElementById("addWork").value,
        total: parseFloat(document.getElementById("addTotal").value),
        totalV: parseFloat(document.getElementById("addTotalV").value),
        in_auswertung: 0,
        teil_projekt_id: parseFloat(document.getElementById("addSubProject").value),
        projekt_id: parseFloat(document.getElementById("addProject").value),
        TimeStamp: entryDate,
        sAuftraggeber: document.getElementById("addContractor").value,
        iidBenutzer: parseFloat(298),//sessionStorage.getItem("userId"),
        akt_id: parseFloat(document.getElementById("addActivity").value)
    };

    WinJS.xhr({
        type: "post",
        url: requestUrl,
        data: JSON.stringify(newEntry),
        headers: {
            "Content-type": "application/json"
        }

    }).then(
          function complete(response) {

          },

Thanks Marlowe

Bimetallism answered 14/5, 2013 at 13:26 Comment(0)
M
2

At least one of your properties has a declared type of Edm.Decimal or Edm.Int64. These values must be serialized as a string (i.e., the number wrapped in " characters) in OData's JSON format. If you're not sure what the declared types of the properties are, you can look up the entity type in the server's $metadata document (typically available at http://.../MyService.svc/$metadata).

So, for the property or properties that are Edm.Int64 or Edm.Decimal, you could remove the call to parseFloat() and just keep it as a string.

Ministrant answered 14/5, 2013 at 17:37 Comment(1)
Immediately below the up and down arrows (at the top left of the answer), there's an outline of a checkmark. You can click that to accept an answer. For a general intro to stackoverflow, you might find this helpful: stackoverflow.com/aboutMinistrant

© 2022 - 2024 — McMap. All rights reserved.