Search code examples
javascripthttporientdborientdb2.2

OrientDB HTTP REST Api Query Unauthorized


I'm getting a 401 unauthorized error on my api request. It works for every other api endpoints(connect, server, class) just not the query endpoint. Does anyone know if additional parameters were needed for authorization?

      fetch(
           'http://localhost:2480/class/query/DB/sql/'+'Select from Results',
           {
                headers: { 'Authorization': 'Basic ' + base64.encode('admin'+":"+'admin')},
            }
       ).then((res)=>{
            console.log(res)
            return res;
       })

Error: {[{code: 401, reason: "Unauthorized", content: "401 Unauthorized."}]}


Solution

  • You can use either "query" or "class" to get informations about a class:

    http://localhost:2480/query/DB/sql/Select from Results
    

     

    http://localhost:2480/class/DB/Results
    

    Keep in mind you can only make GET requests with the "query" command.