Strange bug with REST API

Hello All,

I had an issue this morning while working with my REST API. If I tried to use the JavaScript app.api.call function, as documented here Documentation Class: Api, I ran into the error: "no method" with the message "Could not find a route with x elements". I scoured the internet, looking for anything I could find to make the app.api.call work, but in the end I settled for making my own call to my custom REST API.

So, in short, when using my own calls:

if I use fetch plainly to my custom endpoint: error that says needs authentication

When I use fetch to grab a token using the rest/v10/oauth2 endpoint: get token

Use token  in headers to custom endpoint: works correctly.

When using sugar calls:

Doesn't ask for authentication, just says Could not find a route with x elements.

I have tried using the same exact url that I currently use in my fetch AND postman as the app url, and I still get the error.

I have tried putting different values into the third argument below, such as null, empty object, query strings, etc. Nothing works. I can confirm that the function itself works because it triggers the error block.

app.api.call('POST', app_url, <null or empty object for now>, {
   success: data => {
      console.log(data);
   },

   error: err => {
   console.log('error in fetch email, ' + err);
   }
});

Just to re-iterate, postman and my own fetch work via the url I put in, but not using the sugar app.api.call. It would be nice to avoid having to send refresh tokens or auth by using the already existing user authentication, but maybe I am wrong in assuming that.

Thank you for any insight.

Parents Reply Children
No Data