Api post

I want to post an event data from customized data entry to a program. The payload I created can be imported without any error from Import/Export module but when I try with Ajax post I get the error of 409. I am new to dhis2 api any workaround for it will be much appreciated.

dhis v2.29
built: aaa0fff
tomcat: 8.5.5

               var JsonData = {

“program”: “RxSPAmxTSAd”,
“orgUnit”: “KFDA4CZjN4u”,
“eventDate”: “2019-03-02”,
“status”: “COMPLETED”,
“completedDate”: “2019-03-03”,
“storedBy”: “admin”,
“dataValues”: [
{ “dataElement”: “mGWhRWsdmZ9”, “value”: “CCHF” },
{ “dataElement”: “tNE7jZcgb0u”, “value”: “50” },
{ “dataElement”: “vyyVRZxgHpm”, “value”: “Year” },
{ “dataElement”: “thiap9ppCi8”, “value”: “Name of Deceased” },
{ “dataElement”: “NrrpsQVus6n”, “value”: “Male” },
{ “dataElement”: “NpX4DNHR2Yp”, “value”: “Resident of Deceased” },
{ “dataElement”: “BXGD7swtE2h”, “value”: “None” }
]
};

$.ajax({
        url: 'http://172.16.5.25:8080/dhis/api/events',
        type: 'POST',
        dataType : "json",
        data: JsonData,
        contentType: "application/json",
		
        success: function(data){
            alert('Success');
        },
        error: function(data){
            alert('Error');
        }
    });

@mujtabaomar Essai de modifier l’objet “data : JsonData” par “data : JSON.stringify(JsonData)”

1 Like