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 == '') {