clestcruz 5 days ago

Add JSON data/object to API using ractive

I'm trying to add a JSON data/object to the API using ractive.js but i'm not getting any results. It shows me a response "no content". Not sure what I'm currently missing at the moment. I'm using reactive.js for this project.

This is a sample code that I have been working on.

app.on('addLead', function(event) {
    var proxy        = app.get('proxy');
    var endpoint     = 'account/leads';
    var rt           = 'POST';
    var url          = proxy+'?endpoint'+endpoint+'&rt='+rt;
    data: {
        "id": 10,
        "dateRequested": "2017-01-12",
        "accountIdFk": 0,
        "accountLeadId": 1305981891,
        "accountName": "Noel String",
        "assignedEmployeeIdFk": 10007901,
        "unitNumber": "23",
        "floorNumber": "12",
        "buildingName": "Emerald",
        "streetNumber": "123457",
        "streetName": "Est Street",
        "barangayIdFk": 0,
        "cityTownIdFk": 0,
        "provinceIdFk": 0,
        "regionIdFk": 0,
        "leadsIdentifier": "string",
        "salesRegion": "string",
        "egApproval": "string",
        "smsId": "string",
        "dateComSmsId": "2017-01-09",
        "egRemarks": "string",
        "dateComGbuTag": "2017-01-09",
        "sgRemarks": "string",
    },
});

Answers


Alexandru Mihai 5 days ago

You need to use JSON.stringify().

app.on('addLead', function(event) {
var proxy        = app.get('proxy');
var endpoint     = 'account/leads';
var rt           = 'POST';
var url          = proxy+'?endpoint'+endpoint+'&rt='+rt;
data: JSON.stringify({
    "id": 10,
    "dateRequested": "2017-01-12",
    "accountIdFk": 0,
    "accountLeadId": 1305981891,
    "accountName": "Noel String",
    "assignedEmployeeIdFk": 10007901,
    "unitNumber": "23",
    "floorNumber": "12",
    "buildingName": "Emerald",
    "streetNumber": "123457",
    "streetName": "Est Street",
    "barangayIdFk": 0,
    "cityTownIdFk": 0,
    "provinceIdFk": 0,
    "regionIdFk": 0,
    "leadsIdentifier": "string",
    "salesRegion": "string",
    "egApproval": "string",
    "smsId": "string",
    "dateComSmsId": "2017-01-09",
    "egRemarks": "string",
    "dateComGbuTag": "2017-01-09",
    "sgRemarks": "string",
   }),
});

Post Status

Asked in 5 days ago
Viewed 2,079 times
Voted 9
Answered 1 times

Search




Leave an answer