401 unauthorised response with REST endpoint

Hey guys, I am attempting to use the rest endpoint

I’ve got my stream, I’ve copy pasted an object from Giraffe → QGIS, then pushed it up to Speckle.

Now I want to look at the JSON via the API (then I can figure out how to go from Giraffe → Speckle direct)

So I hit https://speckle.xyz/objects/:5df605b483/:9f1bd909255141961bd5c07b3095012c

5df… is stream id
9f1… is object id (which I got from clicking on my object and copying the id?)

I’ve got a token with all the scope I can give it, but I am getting a 401 from postman… I am assuming it is a basic mistake with the way I am constructing my request. Please help!

Hey @Rob_Asher

I think you need to remove the : from the URL :sweat_smile:, both on the stream ID and the Object ID.

I’ve you’ve got the token correctly set that should work! Let me know if it doesn’t!

3 Likes

I did think that before - I was unfamiliar with this notion - /:xxxxx but when I do I get a 404 Not Found, so I figured it is better to be unauthorised than lost.

I see your problem is with token , let try go to Speckle and create another token and try again.

Next step : create a enviroment for speckle :

And then you can easy set value for authentication token, please note that need add Bear and put “your token”

And then, you can try change to defind like this with parameter is streamid and objectid

2 Likes

Thanks @chuongmep that is really helpful. Here is my current query. I think it is all wired up correctly, but I am still getting that 401.

What am I doing wrong?

1 Like

The correct format for a token is Bearer XXX, but it should (theoretically) work also with a raw XXX.

Your stream is public, so i took a stab: https://speckle.xyz/objects/5df605b483/0a58d406f0a3f88745567733c176be07 - seems to work on my end, without any token. The 9f1etc object does not exist, and I couldn’t find any other commits in there that could point to it.

Alternatively, the graphql query:

query{
  stream(id:"5df605b483"){
    object(id:"0a58d406f0a3f88745567733c176be07") {
      data
    }
  }
}

If you fancy dropping that in the Speckle GraphQL API

Let us know if his helps!

PS: Mind you, the GET objects/stream/id endpoint will give you ALL the object’s subobjects (ie, the complete tree) - we’re using it in the https://npmjs.com/package/@speckle/objectloader js side to download things in the viewer, or iterate through objects as they come in in an ETL fashion, discarding what’s not needed on the way.

PPS: https://speckle.xyz/objects/5df605b483/9f1bd909255141961bd5c07b3095012c returns a 404 :slight_smile: (notice the missing semicolons!)

2 Likes

Let try import my setting had complete and change with your id :
Speckle.postman_collection.json (1.6 KB)
ảnh

3 Likes

Thanks @chuonmep, I imported your requests and added my token as a global called ‘token’ and I still can’t get it to work. As @dimitrie suggested I can get it to work without auth (ie ‘link sharing’ set to true in stream settings), but otherwise I get 401 regardless of whether I use token, Bearer token or Bear token.

I’ll continue on with public data for now, and hand over to someone more competent from my team when I’ve figured the data structure out a bit more, thanks again for all your help

1 Like

@Rob_Asher did you had resole problem yet ? today I have similar problem with input token, may be need invetigate