none
[Node.js][Mobile Service] Azure Mobile services Cordova Plugin issue - Unable to do insert operation RRS feed

  • Question

  • Hello, I am using Azure mobile services plugin for my cordova application.

    I am using VS2015 TACO. I am using Ripple Nexus Galaxy for debugging. I was able to login, read data from mobile service using But While doing insert I am getting below error.

     Can some one help me what causing me this error?

    Here i my complete code using azure mobile service plugin. 

    function authenticate() { mobileService = new WindowsAzure.MobileServiceClient( "https://test.azure-mobile.net/", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); mobileService.login('google').then(function (result) { console.log('1-result',result);

    createEstimate();

    }, function (error) { console.log(error); }); } function createEstimate() { console.log('3-create estimate'); var estimateTable = mobileService.getTable('estimate'); //readEstimateTable(); if (estimateTable !== null || estimateTable !== undefined) { estimateTable.insert(vm.estimate).done(function (sucesss) { console.log('4-success'); console.log(success); }, function (error) { console.log('5-fail'); console.log(error); }); } }



    Vamsidhar M




    Friday, March 18, 2016 6:44 PM

Answers

  • Do you have any custom operations in insert script? if so, could you please post your code in insert script.

    As it is difficult for us to reproduce your issue.

    Your code snippet works fine on my side.

    Tuesday, March 22, 2016 3:01 AM
    Moderator

All replies

  • Hello Vamsidhar M,

    Thank you for posting in here.

    As form your description and your code, I have doubt in this line i.e. estimateTable.insert(vm.estimate).done(function(sucesss).

    Make sure that the vm object which you are using is declared and revert me back with status of the issue, we are happy to assist you with more information.

    Regards,

    Saturday, March 19, 2016 11:11 AM
  • Do you have any custom operations in table operations scripts as the official guide shows at https://azure.microsoft.com/en-us/documentation/articles/mobile-services-how-to-use-server-scripts/#table-scripts?

    And do you get this error message after "5-fail" in your test?

    Monday, March 21, 2016 9:05 AM
    Moderator
  • And do you get this error message after "5-fail" in your test? -  Thats correct. 

    @Sunil Hurkadli, Here is my controller and request. I am getting 404 error. But, I have web application where I can able to insert data using same mobile service url.

    Thanks much for your help.

    Controller.

    (function () {
        'use strict';
        var controllerId = 'estimateController';
        angular.module('ApptimatorApp').controller(controllerId, ['apptimatorService', '$cordovaDialogs', estimateController]);
        function estimateController(apptimatorService, $cordovaDialogs) {
            /* jshint validthis: true */
            var vm = this;
            vm.estimate = {
                'Title': 'CordovaTest',
                'ProposalStartDate': "2016-02-12T05:12:03.923Z",
                'Notes': "Test",
                //'StartDate': "2016-02-12T05:12:03.923Z",
                'Division': "AIS",
                'ManagementCo': 'AIS',
                'ContactCell': '214-493-2977',
                'ContactFax': '214-493-2977',
                'ContactEmail': 'test@gmail.com',
                'Property': 'Property',
                'MeetingRequired': true, //
                'MeetingDate': "2016-02-12T05:12:03.923Z", //
                'resourceName': '21222333-1.zip',
                'userId': 'Tester1@gmail.com',
                'ContactFirstName': 'Vamsi',
                'ContactMiddleName': 'dhar',
                'ContactLastName': 'M',
                'ContactPhone': '214-493-2977',
                'EstimateParentId': '21222333',
                'EstimateId': '21222333-1',
                'EstimateSubId': 1
            };
            vm.createEstimate = createEstimate;
            vm.authenticate = authenticate;
    
            activate();
            var mobileService = {};
            function activate() {
                vm.buildDate = new Date();
                vm.version = '1.1.1';
            }
    
            function authenticate() {
                mobileService = new WindowsAzure.MobileServiceClient(
                  "https://apptimatorrd.azure-mobile.net/",
                  "Xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
              );
                mobileService.login('google').then(function (result) {
                    console.log('1-result',result);                
                    mobileService.invokeApi('getmaxsubid?id=120414', {
                        method: 'GET'
                    }).done(function (response) {
                        console.log('2-invokeApi', response.result);
                    }, function (error) {
                        console.log(error);
                    });
                }, function (error) {
                    console.log(error);
                });
            }
    
            function createEstimate() {                         
                    
                console.log('3-create estimate');           
                var estimateTable = mobileService.getTable('estimate');
                //readEstimateTable();
                if (estimateTable !== null || estimateTable !== undefined) {
                    estimateTable.insert(vm.estimate).done(function (sucesss) {
                        console.log('4-success');
                        console.log(success);
                    }, function (error) {
                        console.log('5-fail');
                        console.log(error);
                    });
                }   
            }
            
    
    })();

    Request URL:https://apptimatorrd.azure-mobile.net/tables/estimate
    Request Method:POST
    Status Code:404 Not Found
    Remote Address:xxx.xx.xx.xx:443
    Response Headers
    Cache-Control:no-cache
    Content-Length:0
    Content-Type:application/json
    Date:Mon, 21 Mar 2016 09:01:05 GMT
    Server:Microsoft-IIS/8.0
    X-Powered-By:ASP.NET
    x-zumo-version:Zumo.master.0.1.6.4401.Runtime
    Request Headers
    POST /tables/estimate HTTP/1.1
    Host: apptimatorrd.azure-mobile.net
    Connection: keep-alive
    Content-Length: 539
    Origin: file://
    X-ZUMO-INSTALLATION-ID: 613125ba-8712-2354-79a5-6fd51b62b477
    X-ZUMO-APPLICATION: ANagbDiFRIQxuvxOMXXXXXXXhCMuDFUaBxPHY68
    User-Agent: Mozilla/5.0 (Linux; Android 5.0; SM-G900H Build/LRX21T; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/48.0.2564.106 Mobile Safari/537.36
    X-ZUMO-AUTH: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjAifQ.eyJleHAiOjE0NjExNDI4NDcsImlzcyI6InVybjptaWNyb3NvZnQ6d2luZG93cy1henVyZTp6dW1vIiwidmXXXXXXXXXX
    Content-Type: application/json
    X-DevTools-Emulate-Network-Conditions-Client-Id: 9DC58B8F-1624-4206-98A6-5XXXXXX4F5
    X-ZUMO-VERSION: ZUMO/1.2 (lang=Cordova; os=--; os_version=--; arch=--; version=1.2.8)
    Accept: */*
    Accept-Encoding: gzip, deflate
    Accept-Language: en-US
    Cookie: ARRAffinity=5ddb7f3ce942ff7d64da90295edc2059785a851ee70bcff72d3b947fa668c797
    X-Requested-With: io.cordova.myapp84a9cc
    Request Payload
    {Title: "CordovaTest", ProposalStartDate: "2016-02-12T05:12:03.923Z", Notes: "Test", Division: "AIS",…}
    ContactCell: "214-493-2977"
    ContactEmail: "test@gmail.com"
    ContactFax: "214-493-2977"
    ContactFirstName: "Vamsi"
    ContactLastName: "M"
    ContactMiddleName: "dhar"
    ContactPhone: "214-493-2977"
    Division: "AIS"
    EstimateId: "21222333-1"
    EstimateParentId: "21222333"
    EstimateSubId: 1
    ManagementCo: "AIS"
    MeetingDate: "2016-02-12T05:12:03.923Z"
    MeetingRequired: true
    Notes: "Test"
    Property: "Property"
    ProposalStartDate: "2016-02-12T05:12:03.923Z"
    Title: "CordovaTest"
    resourceName: "21222333-1.zip"
    userId: "Test@gmail.com"



    Vamsidhar M




    Monday, March 21, 2016 9:20 AM
  • Do you have any custom operations in insert script? if so, could you please post your code in insert script.

    As it is difficult for us to reproduce your issue.

    Your code snippet works fine on my side.

    Tuesday, March 22, 2016 3:01 AM
    Moderator
  • Hello Thanks for your reply.

    You are 100% correct. there is insert script which is validating data before insert. One of the validation fails and script is throwing error.

    Thanks for all your inputs.

    Thursday, March 24, 2016 6:48 AM