[#270] 502 Bad Gateway in login response

Migrated from Redmine #270 | Author: Jacob Heath
Status: Closed | Priority: High, I’m very impatient | Created: 2018-10-24


Our API call worked perfectly, suddenly throws back “502 Bad Gateway” in response.

var options = {
‘method’ : ‘post’,
‘muteHttpExceptions’:true,
‘contentType’: ‘application/json;charset=utf-8’,
‘headers’:{‘Content-Type’:‘application/json’,‘Accept’:‘application/json’,‘charset’:‘UTF-8’},
‘payload’ : JSON.stringify({“jsonrpc”:“2.0”,“method”:“getUserToken”,“params”:[YOUR_COMPANY_LOGIN,YOUR_USER_LOGIN,YOUR_USER_PASSWORD],“id”:1})
};
var response=UrlFetchApp.fetch(‘https://user-api.simplybook.me/login’, options);
if (response.getResponseCode()==200){
var token=JSON.parse(response.getContentText()).result;
options.headers[‘X-Company-Login’]=YOUR_COMPANY_LOGIN;
options.headers[‘X-User-Token’]=token;
}

Did something change?

Redmine Admin wrote:

Fixed. Should be ok now, please check

Jacob Heath wrote:

it passed the first login, but now it gives me another error when I try to access https://user-api.simplybook.me/admin, the response throws back:
{“message”:“Attribute provided with invalid value: Header:null”,“name”:“Exception”,“fileName”:“Code”,“lineNumber”:95,“stack”:“\tat Code:95 (bookData)\n”}

The code:

try{
      var eventId=line[headers.indexOf("eventId (behandling - i tal)")];
      var unitId=line[headers.indexOf("unitId (massørens ID - i tal)")]
      var clientId;
      var clientName=line[headers.indexOf("client")];
      var clientEmail=line[headers.indexOf("email")];
      var clienPhone=line[headers.indexOf("phone")];
      var startDate=line[headers.indexOf("date (in Y-m-d format)")];
      var startTime=line[headers.indexOf("time (in H:i:s format)")];
      var endDate=line[headers.indexOf("endDate (in Y-m-d format)")];
      var endTime=line[headers.indexOf("endTime (in H:i:s format)")];
      var clientTimeOffset=0;
      var add={"promo_code":line[headers.indexOf("promocode")], 
               "promocode":line[headers.indexOf("promocode")], 
               "location_id":line[headers.indexOf("location")],
               "0db3e7523ba2ad3424742eb1f56826c4":line[headers.indexOf("additional_field_1 (address)")],
               "a594df96d2602518ee7644da0a82f203":line[headers.indexOf("additional_field_3 (note)")],
               "838af9e8ecd97e7b75fa1cb07cd422f8":line[headers.indexOf("additional_field_7 (pleje)")],
               "841a80c5c2b3cc2295652f2575c72172":line[headers.indexOf("additional_field_6 (rabatkode)")],
               "9828213cddf686368da0709155b89e50":line[headers.indexOf("additional_field_8")],
              }
      var comment=line[headers.indexOf("comment")];
      // Get Client Id or create new client
      options.payload=JSON.stringify({"jsonrpc":"2.0","method":"addClient","params":[{
                                                                                      name: clientName,
                                                                                      phone: clienPhone,
                                                                                      email: clientEmail,
                                                                                      }],"id":99})
      var response=UrlFetchApp.fetch('https://user-api.simplybook.me/admin', options);
      if (response.getResponseCode()==200){

Redmine Admin wrote:

should be fine already. Please try again. If not working please provide your company login

Jacob Heath wrote:

They work now, nevermind!