UrlFetchApp is returning Error 404 Not Found

318 views
Skip to first unread message

Sid

unread,
May 24, 2019, 8:29:13 AM5/24/19
to Google Apps Script Community
Hello all, as due to previously having questions mark as need editing on stackoverflow, so i couldn't able to post their. Hence i came here.

I am connecting the Voluum flow API using GAS.

I've been able to get the details from Voluum using "GET" method but now this time i have to make some changes ( using "PUT" method ) into their existing flow using flow_id.

I am able to achieve the same using POSTMAN but unable to do that same here using GAS. 

Code/Logic is bit confidential so i can't write here, but i want someone to help me out with this by personally contacting or screen sharing.

It is very strange behavior from GAS side,  i am writing down the below scenario which make more sense,

Step 1: First i am calling Voluum API using GET method to get the flow obj.
Step 2: Now i am parsing the flow response using JSON.parse, so that i can push new object in default array which exist in flow response
Step 3: I am calling Voluum API with update flow response object using PUT method, but i am getting following error
{
  "error" : {
    "time" : "2019-05-24T12:25:13.059829Z",
    "code" : 404,
    "description" : "Not Found"
  }
}

 But here is a catch, when i am skipping step 2, that is if i am getting flow response as it is from GET method and directly putting it to payload for PUT method, then i am not getting any error and its successful call.

What could be the possible hack/or i am missing something?

Please do let me know. I am stuck on it since 3 days.



Eric Koleda

unread,
May 24, 2019, 10:12:51 AM5/24/19
to Google Apps Script Community
I don't think we'll be able to provide much help without at least seeing some code. Perhaps you could remove the sensitive bits and post some of it?

- Eric

Jacob Edward

unread,
May 24, 2019, 2:19:08 PM5/24/19
to Google Apps Script Community

properties.PNG

I'm having a problem with the properties service today...  requests are returning nothing if the GAS code is requesting something from the properties store and when I dig into the settings through the normal UI I'm getting a never ending loading gif

Jacob Edward

unread,
May 24, 2019, 2:19:49 PM5/24/19
to Google Apps Script Community
is your code requesting the properties service?  might not just be my account

Sid

unread,
May 24, 2019, 11:01:53 PM5/24/19
to Google Apps Script Community
Here is the code

//Updating flow by adding new default paths
function addDefaultPathsIntoFlow() {
  
  try{
    
  //Reading sheet to get required details to add default paths.
  var ss          = SpreadsheetApp.getActiveSpreadsheet();
  var sheet       = ss.getSheetByName("Flow Editor");
  
  //Gives no of rows to consider while fetching range from sheet  
  var no_of_row   = ss.getSheetByName("Raw Data Pull").getRange("K3:K3").getValue();
  var dataRange   = sheet.getRange(4,1,no_of_row,7).getValues();
  
  //Each iteration makes one API Call to Voluum   
  for(var i=0; i < dataRange.length; i++){
    
    //default path contains the array of objects, each object represent one default path in flow
    var new_default_path_obj = {
    
    "name"                   : "",    //Required
    "active"                 : "true",
    "weight"                 : "100",
    "offers"                 : [],    //Required, contains offer object, defined below
    "landers"                : [],    //Required, contains lander object, defined below
    "offerRedirectMode"      : "REGULAR",
    "realtimeRoutingApiState": "DISABLED"
  
  }
   
   
    
    var row          = dataRange[i];
    var flow_id      = row[1];
    var default_name = row[2];
    var offer_id     = row[6];
    var lander_id    = row[4];
    
    //assigning the path name
    new_default_path_obj.name = default_name;
    
    //Gettin flow object
    var flow_response        = config.apiCall(config.endpoints.flow, flow_id,'get');   //I have config object in one .gs file where it contains apiCall() method to GET voluum details
    
    flow_response           = JSON.parse(flow_response);
    var default_paths_array = flow_response.defaultPaths;
    
    //Push into new_default_path_obj.landers.push();
    var lander_object = {
      "lander": {
        "id":lander_id,
      },
      "weight":100
    };
    
    //Push into new_default_path_obj.offers.push();
    var offer_object = {
      "offer": {  
        "id" : offer_id,
      },
      "weight":100
    };  
    
    
    //Create new object
    new_default_path_obj.name = default_name;
    new_default_path_obj.offers.push(offer_object);
    new_default_path_obj.landers.push(lander_object);
    
    //Put new object
    default_paths_array.push(new_default_path_obj);
    
 
    console.log(flow_response);   //Prints the final object with newly added default path object in default paths array
    var scriptProperties = PropertiesService.getScriptProperties();
    var options = {
      
      'method' : 'put',
      'headers': {
        'contentType' : 'application/json',
        'cwauth-token': scriptProperties.getProperty("token"),  //getting token required for making request to Voluum
        'Accept'      : 'application/json'
      },
      'muteHttpExceptions' : true,
      'payload'            : flow_response  //I tried using JSON.stringify(flow_response) as well
    }; 
    
     var x = UrlFetchApp.fetch("https://api.voluum.com/flow/f660d3xxxxxxxxxxx04", options);
     console.log(x);  //This is giving me "Not Found" Error msg.

  }

  }catch(e){
    GmailApp.sendEmail("siddhesh...@gmail.com", "Error",e)
  }
    

}



Jacob Edward

unread,
May 25, 2019, 2:13:50 PM5/25/19
to google-apps-sc...@googlegroups.com
So you are using the properties service, have you tried without?  That worked for me...

Sid

unread,
May 26, 2019, 5:57:58 AM5/26/19
to google-apps-sc...@googlegroups.com
How did it work out? You are saying that you put hardcoded token as string in header parameter without property service?
But anyways, i tried commenting out the property service, and put the token as it is hardcoded but didnt worked out.



Mailtrack Sender notified by
Mailtrack 05/26/19, 3:26:11 PM

On Sat, May 25, 2019 at 11:43 PM Jacob Edward <oughtimp...@gmail.com> wrote:
So you are using the properties service, have you tried without?  That worked for me

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-script-community.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/58e31435-8832-44e0-9358-4e2692405d9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Siddhesh Mishra

Sid

unread,
May 26, 2019, 8:41:46 AM5/26/19
to google-apps-sc...@googlegroups.com
Same this is working fine on voluum api explorer and postman, but this is not working here using google apps script. And i am able to GET the data from Voluum API but not in case of PUT. 

image.png



This is what i am getting.
--
Siddhesh Mishra

Sid

unread,
May 29, 2019, 12:41:03 AM5/29/19
to google-apps-sc...@googlegroups.com
Anyone to help ?
Can anyone get this project details and just do a simple POC on that?
I tried connecting with nodejs and it worked there too. But here in GAS with multiple trials didnt get any luck. 
--
Siddhesh Mishra

Martin Hawksey

unread,
May 29, 2019, 1:53:29 AM5/29/19
to google-apps-sc...@googlegroups.com
Sounds like you've exhausted options from Apps Script. Are you able to open a ticket with voluum to make sure they are not blocking the call from apps script?

Sid

unread,
May 29, 2019, 5:33:20 AM5/29/19
to google-apps-sc...@googlegroups.com
Hi Martin, It this would have been the case, then i wouldn't be getting data from voluum using GET method. Do you think still i should raise this concern? Because i already had a long email chats with thier support team, they told me that request details are correct using CURL they tried. 


For more options, visit https://groups.google.com/d/optout.


--
Siddhesh Mishra

Martin Hawksey

unread,
May 29, 2019, 6:20:54 AM5/29/19
to Google Apps Script Community
Good point on the GET. To debug further you could use the Postman Echo to check the headers and payload from your code aren't malformed. You could also use the response from the echo if you need to open another ticket with voluum so they can check the call. I've just dummied to check nothing is being stripped from the header and you might want to replace your PUT call to voluum with https://postman-echo.com/put in your code to make sure properties are being included 

function myFunction() {
  var options = {
    'method' : 'PUT',
    'headers': {
      'contentType' : 'application/json',
      'cwauth-token': 'A_TOKEN_HERE',  //getting token required for making request to Voluum
      'Accept'      : 'application/json'
    },
    'muteHttpExceptions' : true,
    'payload'            : {foo:'bar'}  //I tried using JSON.stringify(flow_response) as well
  }; 
  var resp = JSON.parse(UrlFetchApp.fetch("https://postman-echo.com/put", options).getContentText());
}
Here is the code

    GmailApp.sendEmail("siddheshmishr...@gmail.com", "Error",e)
  }
    

}









On Friday, May 24, 2019 at 7:42:51 PM UTC+5:30, Eric Koleda wrote:
I don't think we'll be able to provide much help without at least seeing some code. Perhaps you could remove the sensitive bits and post some of it?

- Eric

On Friday, May 24, 2019 at 8:29:13 AM UTC-4, sidmish wrote:
Hello all, as due to previously having questions mark as need editing on stackoverflow, so i couldn't able to post their. Hence i came here.

I am connecting the Voluum flow API using GAS.

I've been able to get the details from Voluum using "GET" method but now this time i have to make some changes ( using "PUT" method ) into their existing flow using flow_id.

I am able to achieve the same using POSTMAN but unable to do that same here using GAS. 

Code/Logic is bit confidential so i can't write here, but i want someone to help me out with this by personally contacting or screen sharing.

It is very strange behavior from GAS side,  i am writing down the below scenario which make more sense,

Step 1: First i am calling Voluum API using GET method to get the flow obj.
Step 2: Now i am parsing the flow response using JSON.parse, so that i can push new object in default array which exist in flow response
Step 3: I am calling Voluum API with update flow response object using PUT method, but i am getting following error
{
  "error" : {
    "time" : "2019-05-24T12:25:13.059829Z",
    "code" : 404,
    "description" : "Not Found"
  }
}

 But here is a catch, when i am skipping step 2, that is if i am getting flow response as it is from GET method and directly putting it to payload for PUT method, then i am not getting any error and its successful call.

What could be the possible hack/or i am missing something?

Please do let me know. I am stuck on it since 3 days.



--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.


--
Siddhesh Mishra


--
Siddhesh Mishra


--
Siddhesh Mishra

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.


--
Siddhesh Mishra

Sid

unread,
May 29, 2019, 7:14:08 AM5/29/19
to google-apps-sc...@googlegroups.com
this is what i got, 

{
  "args": {
   
  },
  "data": "",
  "files": {
   
  },
  "form": {
    "updatedTime": "2019-05-28T16:40:57.689Z",
    "workspace": "{id=cf5777c6-c6a8-4a5e-9e91-0d738f02dced}",
    "allowedActions": "[Ljava.lang.Object;@35cc62c8",
    "countries": "[Ljava.lang.Object;@20e5f937",
    "defaultPaths": "[Ljava.lang.Object;@4f8df62a",
    "deleted": "false",
    "name": "Global - Test Flow sid",
    "defaultOfferRedirectMode": "REGULAR",
    "createdTime": "2019-05-10T04:53:58.219Z",
    "realtimeRoutingApi": "DISABLED",
    "automationConfiguration": "{calculationMethod=AUTO, autoOptimized=false}",
    "id": "f660d3b2-bd4c-458c-9575-920bf31f8c04",
    "conditionalPathsGroups": "[Ljava.lang.Object;@7bf23868"
  },
  "headers": {
    "x-forwarded-proto": "https",
    "host": "postman-echo.com",
    "content-length": "563",
    "accept": "application/json",
    "accept-encoding": "gzip,deflate,br",
    "content-type": "application/x-www-form-urlencoded",
    "contenttype": "application/x-www-form-urlencoded",
    "cwauth-token": "OPNScMSqOf85clCAr8xsS_OAJ_gKo4sW",
    "user-agent": "Mozilla/5.0 (compatible; Google-Apps-Script)",
    "x-forwarded-port": "443"
  },
  "json": {
    "updatedTime": "2019-05-28T16:40:57.689Z",
    "workspace": "{id=cf5777c6-c6a8-4a5e-9e91-0d738f02dced}",
    "allowedActions": "[Ljava.lang.Object;@35cc62c8",
    "countries": "[Ljava.lang.Object;@20e5f937",
    "defaultPaths": "[Ljava.lang.Object;@4f8df62a",
    "deleted": "false",
    "name": "Global - Test Flow sid",
    "defaultOfferRedirectMode": "REGULAR",
    "createdTime": "2019-05-10T04:53:58.219Z",
    "realtimeRoutingApi": "DISABLED",
    "automationConfiguration": "{calculationMethod=AUTO, autoOptimized=false}",
    "id": "f660d3b2-bd4c-458c-9575-920bf31f8c04",
    "conditionalPathsGroups": "[Ljava.lang.Object;@7bf23868"
  },
  "url": "https://postman-echo.com/put"
}

Here is the code

    GmailApp.sendEmail("siddhesh...@gmail.com", "Error",e)
  }
    

}









On Friday, May 24, 2019 at 7:42:51 PM UTC+5:30, Eric Koleda wrote:
I don't think we'll be able to provide much help without at least seeing some code. Perhaps you could remove the sensitive bits and post some of it?

- Eric

On Friday, May 24, 2019 at 8:29:13 AM UTC-4, sidmish wrote:
Hello all, as due to previously having questions mark as need editing on stackoverflow, so i couldn't able to post their. Hence i came here.

I am connecting the Voluum flow API using GAS.

I've been able to get the details from Voluum using "GET" method but now this time i have to make some changes ( using "PUT" method ) into their existing flow using flow_id.

I am able to achieve the same using POSTMAN but unable to do that same here using GAS. 

Code/Logic is bit confidential so i can't write here, but i want someone to help me out with this by personally contacting or screen sharing.

It is very strange behavior from GAS side,  i am writing down the below scenario which make more sense,

Step 1: First i am calling Voluum API using GET method to get the flow obj.
Step 2: Now i am parsing the flow response using JSON.parse, so that i can push new object in default array which exist in flow response
Step 3: I am calling Voluum API with update flow response object using PUT method, but i am getting following error
{
  "error" : {
    "time" : "2019-05-24T12:25:13.059829Z",
    "code" : 404,
    "description" : "Not Found"
  }
}

 But here is a catch, when i am skipping step 2, that is if i am getting flow response as it is from GET method and directly putting it to payload for PUT method, then i am not getting any error and its successful call.

What could be the possible hack/or i am missing something?

Please do let me know. I am stuck on it since 3 days.



--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.


--
Siddhesh Mishra


--
Siddhesh Mishra


--
Siddhesh Mishra

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.


--
Siddhesh Mishra

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Siddhesh Mishra

Sid

unread,
May 29, 2019, 7:17:59 AM5/29/19
to google-apps-sc...@googlegroups.com
I am so sorry , if im sounding silly, i am inexperienced in postman echo, so what to derive from the response of this i dont know. Its been a week though i am stuck on this. 

--
Siddhesh Mishra

Sid

unread,
May 29, 2019, 8:57:02 AM5/29/19
to google-apps-sc...@googlegroups.com
Any suggestions?
--
Siddhesh Mishra

Adam Morris

unread,
May 29, 2019, 9:38:10 AM5/29/19
to google-apps-sc...@googlegroups.com
Can you share the curl example?


For more options, visit https://groups.google.com/d/optout.
--
————————————————————————————

Adam Morris | IT Systems & English Teacher | IGB International School
Jalan Sierramas Utama, Sierramas,
47000 Sungai Buloh, Selangor DE, Malaysia

t    +60 3 6145 4688
f    +60 3 6145 4600
w   www.igbis.edu.my
e    adam....@igbis.edu.my

————————————————————————————

Sid

unread,
May 29, 2019, 9:45:18 AM5/29/19
to google-apps-sc...@googlegroups.com
This is what im doing in GAS, 
var flow_response = {
   //Required format
}

var options = {
     
      'method' : 'put',
      'headers': {
        'contentType' : 'application/json',
        'cwauth-token':  scriptProperties.getProperty("token"),    //Every 4 hour get expired

        'Accept'      : 'application/json'
      },
      'muteHttpExceptions' : true,
      'payload'            : flow_response

    };
    var url = "https://postman-echo.com/put";
//    var url = "https://panel-api.voluum.com/flow/f660d3b2-bd4c-458c-9575-920bf31f8c04";  //Main URL
     var x = UrlFetchApp.fetch(url, options);
     Logger.log(x);

-------------------------------------------
Logger is giving me the Error 404
Yesterday i tried that using node js, it worked fine.



For more options, visit https://groups.google.com/d/optout.


--
Siddhesh Mishra

Sid

unread,
May 29, 2019, 9:46:50 AM5/29/19
to google-apps-sc...@googlegroups.com
This is what i am getting from postman echo ,

{
  "args": {
   
  },
  "data": "",
  "files": {
   
  },
  "form": {
    "updatedTime": "2019-05-28T16:40:57.689Z",
    "workspace": "{id=cf5777c6-c6a8-4a5e-9e91-0d738f02dced}",
    "allowedActions": "[Ljava.lang.Object;@6e7a8540",
    "countries": "[Ljava.lang.Object;@6c3b0530",
    "defaultPaths": "[Ljava.lang.Object;@34fb7988",

    "deleted": "false",
    "name": "Global - Test Flow sid",
    "defaultOfferRedirectMode": "REGULAR",
    "createdTime": "2019-05-10T04:53:58.219Z",
    "realtimeRoutingApi": "DISABLED",
    "automationConfiguration": "{calculationMethod=AUTO, autoOptimized=false}",
    "id": "f660d3b2-bd4c-458c-9575-920bf31f8c04",
    "conditionalPathsGroups": "[Ljava.lang.Object;@60c02176"

  },
  "headers": {
    "x-forwarded-proto": "https",
    "host": "postman-echo.com",
    "content-length": "563",
    "accept": "application/json",
    "accept-encoding": "gzip,deflate,br",
    "content-type": "application/x-www-form-urlencoded",
    "contenttype": "application/json",
    "cwauth-token": "padbikjZ1Jh-yuwrWsdLe6dtHbQ7DK0P",

    "user-agent": "Mozilla/5.0 (compatible; Google-Apps-Script)",
    "x-forwarded-port": "443"
  },
  "json": {
    "updatedTime": "2019-05-28T16:40:57.689Z",
    "workspace": "{id=cf5777c6-c6a8-4a5e-9e91-0d738f02dced}",
    "allowedActions": "[Ljava.lang.Object;@6e7a8540",
    "countries": "[Ljava.lang.Object;@6c3b0530",
    "defaultPaths": "[Ljava.lang.Object;@34fb7988",

    "deleted": "false",
    "name": "Global - Test Flow sid",
    "defaultOfferRedirectMode": "REGULAR",
    "createdTime": "2019-05-10T04:53:58.219Z",
    "realtimeRoutingApi": "DISABLED",
    "automationConfiguration": "{calculationMethod=AUTO, autoOptimized=false}",
    "id": "f660d3b2-bd4c-458c-9575-920bf31f8c04",
    "conditionalPathsGroups": "[Ljava.lang.Object;@60c02176"
  },
  "url": "https://postman-echo.com/put"
}
--
Siddhesh Mishra

Adam Morris

unread,
May 29, 2019, 10:05:54 AM5/29/19
to google-apps-sc...@googlegroups.com
Troubleshooting is tricky, but it's even harder for us to do when we aren't able to reproduce the problem. I suggest you read the documentation thoroughly and figure out how to reproduce the problem so that they can diagnose, hand off to them in a way where all they have to do is click and see it. (Maybe share the script with them directly.)

I took a look at the documentation, and noticed this:

"Moreover, the access keys have lower privileges and are blocked by some of the Voluum endpoints, thus your data is safe, even if the access key is stolen"

The endpoint you are using /flow is not on the list of endpoints that block if access key is used, but it might be worth querying them to ask if that endpoint was perhaps left off the list by accident. 


————————————————————————————

Adam Morris | IT Systems & English Teacher | IGB International School
Jalan Sierramas Utama, Sierramas,
47000 Sungai Buloh, Selangor DE, Malaysia

t    +60 3 6145 4688
f    +60 3 6145 4600
w   www.igbis.edu.my
e    adam....@igbis.edu.my

————————————————————————————

Sid

unread,
May 29, 2019, 10:11:09 AM5/29/19
to google-apps-sc...@googlegroups.com
Thanks adam, i will do that. 


For more options, visit https://groups.google.com/d/optout.


--
Siddhesh Mishra

Riël Notermans

unread,
May 29, 2019, 10:43:11 AM5/29/19
to Google Apps Script Community
I see the flow API docs have a test page. You can do the call there as well.

If I check the docs and the code, IT seems like issue is with Voluum, or you are using the wrong flow_id in your URL.

I really do not think the issue is with urlFetchApp.



Op wo 29 mei 2019 16:11 schreef siddhesh mishra <siddhesh...@gmail.com>:

Sid

unread,
May 29, 2019, 10:52:51 AM5/29/19
to google-apps-sc...@googlegroups.com
Hi there
I tried that, it worked there with success!
And i had put the SAME FLOW ID there on voluum playground as well. Exact same thing i have completed in node js application. So currently for time concern, i am moving the platform to node js and i will be passing the data from GAS to node js and node js will call Voluum. 


For more options, visit https://groups.google.com/d/optout.


--
Siddhesh Mishra
Reply all
Reply to author
Forward
0 new messages