Start a new topic

Trying out the REST API

I just tested this REST API example (from: here https://v3yk1n-devcenter.herokuapp.com/html5/reference/business-logic/reference.html#request-module). But I changed the uri to my own which will return with a useful response. 


But with this example I get error:  400 ERROR -- { "error": "BLRuntimeError", "description": "The Business Logic script has a runtime error. See debug message for details.", "debug": "ReferenceError: onRequest is not defined" }


What is wrong with the example?


For example:

var req = modules.request;req.request({uri: 'http://api.example-api.com/v1/abcdefg',             method: 'GET'},            function(error, res, body){            if (error){                response.body = {error: error.message};                response.complete(434);            } else {                response.body = JSON.parse(body);                response.complete(res.status);            }});

I am testing out Kinvey and to start with I am trying to see if it is possible to access a third party REST API. 


My main goal is to build a Proxy that exposes a set of endpoints to logged in users from an Angular web app. To do that I need to either build my own Proxy server or use a BaaS that is CORS enabled. 


I have managed to build a BL custom endpoint and access (as I have described). Now I am trying access it from the API console. But due to lack of documentation I am not able to figure out the name of the endpoint (which I also have described).

 

PS!

You have a very strange forum and your documentation is lacking a lot of information. 

It is rely a very simple question:


I am trying to access my custom endpoint in the API Console but is only getting error response.


I have tried with all kind of combinaitons: /rpc/custom, /appdata/rpc/, /appdata/kid_WJBMffozR/rpc/custom/access_token


It would be convenient to have some information somewhere about the name of your endpoints. I have read all about the REST API and BL and references and here in the forum but have not find it anywhere.


/appdata/kid_WJBMffozR/access_token/

and get the response:

POST /appdata/kid_WJBMffozR/access_token/

Authorization: Basic a2lkX1dKQk1mZm96UjoyN2E1OTFlMzlkNDE0MDRkYjhhYmYwZWU4MzhiZDgyOA== 
X-Kinvey-API-Version: 3

================

HTTP/1.1 400 ERROR 
Mon Apr 13 2015 13:43:13 GMT+0200 (CEST)


"error": "InvalidIdentifier", 
"description": "One of more identifier names in the request has an invalid format", 
"debug": "The collectionName in the request may only contain alphanumeric characters and dashes" 
}

I found out what was missing in your code example. So this is solved as I wrote in another post. But not the other topic and they are not about the same issue. They are also described very clearly and should be possible to understand.

Solved