Quantcast
Viewing latest article 18
Browse Latest Browse All 62

adding to playbook without entity

Hi

I am trying to upload a status using api.But it is giving me the status that i am uploading it without entity.As far as i think i am doing the code right could you plz tell me what could be the problem.here is my code

function apiCreateItem() {
    var httpClient = Ti.Network.createHTTPClient();
    httpClient.setTimeout(5000);
    httpClient.setTimeout(5000);
    var url = 'https://www.sportscrunch.com/api/v1/playbook/add';
    httpClient.onerror = function(e) {
        alert("API CREATE ITEM: " + this.status);
        var error = this.responseText.replace(/<[^>]+>/g, '');
        Ti.API.info(error);
        Ti.App.fireEvent('createdItem', {
            responseJSON : null
        });
    }
 
    httpClient.onload = function() {
        Ti.API.info("API CREATE ITEM: " + this.status);
 
        if (this.status == 201) {
            var responseJSON = JSON.parse(this.responseText);
            Ti.App.fireEvent('createdItem', {
                responseJSON : responseJSON
            });
        } else {
            var error = this.responseText.replace(/<[^>]+>/g, '');
            Ti.API.info(error);
            Ti.App.fireEvent('createdItem', {
                responseJSON : null
            });
        }
    };
 
    var item = 'I am very good titanium developer';
 
    var json = JSON.stringify(item);
 
    httpClient.open("POST", url);
    httpClient.setRequestHeader("Content-Type", "application/json");
    httpClient.send(json);
}
 
apiCreateItem();

Thanks


Viewing latest article 18
Browse Latest Browse All 62

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>