0

When I try to run the Shipify example in the Salesforce1 Mobile App Developer Guide, I get this message.

First make HTTP POST to "/" w/ Salesforce signed-request. HTTP GET to "/" is not allowed

Does anybody know what's going on?


I found the code that generates the message.

https://github.com/forcedotcom/Shipify-Node-App/blob/master/views/index.ejs

$(document).ready(function(){ if(access_token == '' || instance_url == '' || warehouseId == '') { alert('First make HTTP POST to "/" w/ Salesforce signed-request. HTTP GET to "/" is not allowed'); return; }

But I don't have enough context to know why the access_token would be an empty string.


The alert box that pops up when I click Shipify from the Chatter tab says this:

An embedded page at blooming-crag-22270.herokuapp.com says: First make HTTP POST to "/" w/ Salesforce signed-request. HTTP GET to "/" is not allowed

A $ heroku logs --tail yields this when I click Shipify from the Chatter tab:

2016-07-14T13:19:59.149392+00:00 heroku[web.1]: Unidling 2016-07-14T13:19:59.149986+00:00 heroku[web.1]: State changed from down to starting 2016-07-14T13:20:01.098059+00:00 heroku[web.1]: Starting process with command `node app.js` 2016-07-14T13:20:02.906473+00:00 app[web.1]: Running on: port 51419 2016-07-14T13:20:02.913713+00:00 app[web.1]: process.env.RUNNING_ON_HEROKU = true 2016-07-14T13:20:03.429120+00:00 heroku[web.1]: State changed from starting to up 2016-07-14T13:20:04.242851+00:00 app[web.1]: POST /signedrequest 200 34ms - 5.69kb 2016-07-14T13:20:04.354310+00:00 app[web.1]: GET /stylesheets/Mobile-Design-Templates-master/common/css/app.min.css 304 10ms 2016-07-14T13:20:04.355901+00:00 app[web.1]: GET /stylesheets/Mobile-Design-Templates-master/common/js/main.min.js 304 7ms 2016-07-14T13:20:04.356897+00:00 app[web.1]: GET /stylesheets/Mobile-Design-Templates-master/common/js/jquery.touchwipe.min.js 304 7ms 2016-07-14T13:20:04.358890+00:00 heroku[router]: at=info method=GET path="/stylesheets/Mobile-Design-Templates-master/common/js/jquery.touchwipe.min.js" host=blooming-crag-22270.herokuapp.com request_id=74806678-6863-439d-96d4-b035167bd407 fwd="168.93.73.226" dyno=web.1 connect=0ms service=18ms status=304 bytes=237 2016-07-14T13:20:04.234185+00:00 heroku[router]: at=info method=POST path="/signedrequest" host=blooming-crag-22270.herokuapp.com request_id=c4e82bcc-8ba9-4411-bedb-59c32acbdc81 fwd="168.93.73.226" dyno=web.1 connect=0ms service=33ms status=200 bytes=6004 2016-07-14T13:20:04.357081+00:00 heroku[router]: at=info method=GET path="/stylesheets/Mobile-Design-Templates-master/common/css/app.min.css" host=blooming-crag-22270.herokuapp.com request_id=4e9905f9-0127-4a20-9eca-534e5375ed15 fwd="168.93.73.226" dyno=web.1 connect=0ms service=18ms status=304 bytes=239


Aha! Output in the console log is this, with the code below.

access_token = "00D36000001Fb8u!AQQAQNKzBEm5lv6ZPmT8IWxDwnts9zUcCcXJyS.BgGqTYgEJkdhXoXDyDEI109ZTDJfQlfIO_q88HHOq1q6w8e2iB_6.Ib43", instance_url = "https://na30.salesforce.com", warehouseId = ""

```

    //Note: Values of the variables below are set by the server.
    var access_token = '<%= oauthToken %>';
    var instance_url = '<%= instanceUrl %>';
    var warehouseId = '<%= warehouseId %>';

    console.log('access_token = "' + access_token + '", instance_url = "' + instance_url +
            '", warehouseId = "' + warehouseId + '"');

    $(document).ready(function(){
      if(access_token == '' || instance_url == '' || warehouseId == '') {
        alert('First make HTTP POST to "/" w/ Salesforce signed-request. HTTP GET to  "/" is not allowed');
        return;
      }
        getInvoices();
    });

```

It's warehouseId that is missing. I bet the code is just fragile, and it doesn't handle missing data well. How do I set up the data so that a warehouseId will be there?


Elsewhere in the code, it says that warehouseId is optional. I removed the check for warehouseId, and it worked!

$(document).ready(function(){ // Some places in the code, it suggests that warehouseId is optional. // I'll try just taking it out, since I don't have one. // if(access_token == '' || instance_url == '' || warehouseId == '') { if(access_token == '' || instance_url == '') {

  • did u find the solution for this(First make HTTP POST to "/" w/ Salesforce signed-request. HTTP GET to "/" is not allowed) problem ?? – Ayush Nagpal Mar 15 '17 at 15:39
2

Please double check that you are using the POST method (not GET) in the Canvas Settings as shown here.

enter image description here

Specifically, step 10 mentioned in the guide is important here.

  1. In the Access Method drop-down list, select Signed Request (POST).

This is by default set to GET and is most likely causing the issue at your end.

| improve this answer | |
  • Hi, Gaurav. The Canvas App Settings - Access Method is set to Signed Request (POST). (I tried to paste an image but I failed.) I edited the question and included the code that is generating the error, if that helps. – user2171796 Jul 14 '16 at 12:02
  • Another fellow said that the problem went away when he "created and deployed his Salesforce Developer Domain" ( salesforce.stackexchange.com/questions/106341/… ) but I don't know what that means. – user2171796 Jul 14 '16 at 13:07
  • Is there some org where this is working, that I can compare to? – user2171796 Jul 14 '16 at 13:07
  • I added the heroku logs to the question. Looks to me like /signedrequest gets posted first, contrary to what the error message seems to be saying. – user2171796 Jul 14 '16 at 13:33
  • I figured out which data item is missing. Probably the program just doesn't handle it well when the data isn't set up. – user2171796 Jul 14 '16 at 15:06
0

It turns out that the warehouseId is optional, and we don't have one. I changed the code so that it doesn't quit if warehouseId is missing.

In the views/index.ejs file:

$(document).ready(function(){ // Some places in the code, it suggests that warehouseId is optional. // I'll try just taking it out, since I don't have one. // if(access_token == '' || instance_url == '' || warehouseId == '') { if(access_token == '' || instance_url == '') {

| improve this answer | |
  • I still wonder how other people made the code sample work. Did they have a warehouseId? – user2171796 Jul 14 '16 at 15:23

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.