0

In my app, I am fetching data, editing and re-submitting it. That's where I am getting Could not find resource node.. However, node is enabled under Resources. Besides, I am not getting any errors fetching data. I was following this guide. How to handle this situation? My code is as follows:

$.ajax({
    url: 'http://www.rejicast.com/services/user/token.json',
    type: 'post',
    dataType: 'json',
    success: function(token) {
        localStorage.token = token.token;
        $.ajax({
            url: 'http://www.rejicast.com/services/system/connect.json',
            type: 'post',
            dataType: 'json',
            beforeSend: function(r) {
                r.setRequestHeader("X-CSRF-Token", localStorage.token)
            },
            success: function(data) {
                $.ajax({
                    url: 'http://www.rejicast.com/oyuncularim.json',
                    type: 'get',
                    dataType: 'json',
                    data: {
                        uid_raw: localStorage.uid
                    },
                    success: function (data) {
                        nid = data.nodes[0].node.nid;
                        console.log(JSON.stringify(data));
                        $("#otherpicture").attr("src", data.nodes[0].node.field_fotograflar.src);
                        /*
                        $("#otherpicture-2").attr("src", data.nodes[1].node.field_fotograflar.src);
                        $("#otherpicture-3").attr("src", data.nodes[2].node.field_fotograflar.src);
                        $("#otherpicture-4").attr("src", data.nodes[3].node.field_fotograflar.src);
                        $("#otherpicture-5").attr("src", data.nodes[4].node.field_fotograflar.src);
                        */
                        $("#name").val(data.nodes[0].node.title);
                        $("#tckn").val(data.nodes[0].node.field_tc_kimlik_no);
                        $("#dob").val(data.nodes[0].node.field_dogum_tarihi_1);
                        $("#email").val(data.nodes[0].node.field_e_posta);
                        $("#tel").val(data.nodes[0].node.field_telefon);
                        $("#tel2").val(data.nodes[0].node.field_telefon_2);
                        $("#address").val(data.nodes[0].node.field_adres);
                        $("#city option:contains('"+data.nodes[0].node.field_yasadigi_sehir+"')").prop("selected", "selected");
                        $("#gender option[innerHTML="+data.nodes[0].node.field_cinsiyet+"]").prop("selected", "selected");
                        $("#chest option:contains('"+data.nodes[0].node.field_sehir+"')").prop("selected", "selected");
                        $("#waist option:contains('"+data.nodes[0].node.field_bel+"')").prop("selected", "selected");
                        $("#thigh option:contains('"+data.nodes[0].node.field_kalca+"')").prop("selected", "selected");
                        $("#weight option:contains('"+data.nodes[0].node.field_kilo+"')").prop("selected", "selected");
                        $("#height option:contains('"+data.nodes[0].node.field_boy+"')").prop("selected",true);
                        $("#eyecolour option:contains('"+data.nodes[0].node.field_goz_rengi+"')").prop("selected", "selected");
                        $("#skincolour option:contains('"+data.nodes[0].node.field_ten_rengi+"')").prop("selected", "selected");
                        $("#shoesize").val(data.nodes[0].node.field_ayak_no);
                        $("#education").val(data.nodes[0].node.field_egitim_duzeyi);
                        $("#training").val(data.nodes[0].node.field_oyunculuk_egitimleri);
                        $("#skills").val(data.nodes[0].node.field_beceriler);
                        $("#languages").val(data.nodes[0].node.field_diller);
                        $("#personal").val(data.nodes[0].node.field_kisisel);
                        $(".videolink").val(data.nodes[0].node.field_videolar);
                    }
                });
            }
        });
    }
});
$("#edit").on("click", function() {
    ActivityIndicator.show("Face in Cast", "Düzeltme yapılıyor, lütfen bekleyin");
    monthNames = [
        "Oca", "Şub", "Mar",
        "Nis", "May", "Haz", "Tem",
        "Ağu", "Eyl", "Eki",
        "Kas", "Ara"
    ];
    date = new Date($("#dob").val());
    day = date.getDate();
    monthIndex = date.getMonth();
    year = date.getFullYear();
    finalDate = day+' '+monthNames[monthIndex]+' '+year;
    var fid = '';
    $.each(fids, function(k,v) {
        fid += '&node[field_fotograflar][und]['+k+'][fid]='+v;
    });
    var cat = '';
    $('#oyuncuKategori input:checked').each(function(k,v) {
        cat += '&node[field_kategorisi][und]['+k+']='+$(this).attr('id');
    });
    $.ajax({
        url:'http://www.rejicast.com/services/node/'+nid+'.json',
        type:'put',
        dataType:'json',
        beforeSend: function(r) {
            r.setRequestHeader("X-CSRF-Token", localStorage.token)
        },
        data:'node[type]=oyuncu&node[title]='+encodeURIComponent($("#name").val())+'&node[language]=und&node[field_tc_kimlik_no][und][0][value]='+encodeURIComponent($("#tckn").val())+'&node[field_sgk_durumu][und][value]='+encodeURIComponent($("#sgk option:selected").val())+cat+'&node[field_telefon][und][0][value]='+encodeURIComponent($("#tel").val())+'&node[field_telefon_2][und][0][value]='+encodeURIComponent($("#tel2").val())+'&node[field_adres][und][0][value]='+encodeURIComponent($("#address").val())+'&node[field_yasadigi_sehir][und][value]='+encodeURIComponent($("#city option:selected").val())+'&node[field_e_posta][und][0][value]='+encodeURIComponent($("#email").val())+'&node[field_cinsiyet][und][value]='+encodeURIComponent($("#gender option:selected").val())+'&node[field_gogus][und][value]='+$("#chest option:selected").val()+'&node[field_bel][und][value]='+$("#waist option:selected").val()+'&node[field_kalca][und][value]='+$("#thigh option:selected").val()+'&node[field_dogum_tarihi][und][0][value][date]='+finalDate+'&node[field_boy][und][value]='+encodeURIComponent($("#height option:checked").val())+'&node[field_kilo][und][value]='+encodeURIComponent($("#weight option:selected").val())+'&node[field_goz_rengi][und][value]='+encodeURIComponent($("#eyecolour option:selected").val())+'&node[field_ten_rengi][und][value]='+encodeURIComponent($("#skincolour option:selected").val())+'&node[field_ayak_no][und][value]='+encodeURIComponent($("#shoesize option:selected").val())+'&node[field_egitim_duzeyi][und][value]='+encodeURIComponent($("#education option:selected").val())+'&node[field_oyunculuk_egitimleri][und][0][value]='+encodeURIComponent($("#training").val())+'&node[field_diller][und][0][value]='+encodeURIComponent($("#languages").val())+'&node[field_beceriler][und][0][value]='+encodeURIComponent($("#skills").val())+'&node[field_kisisel][und][0][value]='+encodeURIComponent($("#personal").val())+'&node[field_videolar][und][0][video_url]='+encodeURIComponent($(".videolink").val())+'&node[field_videolar][und][0][description]='+encodeURIComponent($(".videodesc").val())+'&node[field_yapim_yili][und][value]='+encodeURIComponent(finalDate)+'&node[field_okudum_anladim][und][value]='+encodeURIComponent($(".privacy").is(':selected')?1:0),
        success:function(data) {
            ActivityIndicator.hide();
            navigator.notification.alert("Kaydınız başarıyla düzenlendi", function() {return;}, "Face in Cast", "Tamam");
        },
        error:function(xhr,status,message) {
            console.log(xhr);
            console.log(status);
            console.log(message);
            navigator.notification.alert("Eksik bırakılan alan var, lütfen doldurup tekrar deneyin.", function(){return;}, "Hata", "Tamam");
        }
    });
});

UPDATE:

my services settings screenshot my resources screenshot

3
  • What's the machine name and path for your Services endpoint? In your code, replace services with the aforementioned path and you should be all set. Do that for all of them except the token retrieval, because services/session/token is the correct path to use. May 10 '16 at 19:57
  • @tyler.frankenstein they are both "services". Besides, all of them (except edit) are already working.
    – Kartagis
    May 11 '16 at 5:32
  • @tyler.frankenstein please see my screenshots above
    – Kartagis
    May 12 '16 at 13:46
0

I removed the alias and it worked :) Apparently resource name doesn't work if I assign an alias to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.