Not possible to fetch private stream branches using GraphQL API

Hi,
I have problems in fetching brachnes from a private stream.

Can you test it in Windows using curl ? Also I had issues with double quotes with curl in Windows.

curl https://speckle.xyz/graphql -H “Accept-Encoding: gzip, deflate, br” -H “Content-Type: application/json” -H “Accept: application/json” -H “Connection: keep-alive” -H “DNT: 1” -H “Origin: https://speckle.xyz” -H “Authorization: Bearer yourbearer” --data-compressed “@com.txt” --compressed

where com.txt contains

{“query”:" query{stream(id:“yourstreamid”){id name}}"}

Also tested Unreal Engine, but it fetches only the branches for public streams.
Also tested the provided curl (the one automatically generated by pressing CURL button in the playground) but no lack:

curl ‘https://speckle.xyz/graphql’ -H ‘Accept-Encoding: gzip, deflate, br’ -H ‘Content-Type: application/json’ -H ‘Accept: application/json’ -H ‘Connection: keep-alive’ -H ‘DNT: 1’ -H ‘Origin: https://speckle.xyz’ -H ‘Authorization: Bearer myBearer’ --data-binary ‘{\“query\”:\" query{stream(id:\“myStreamId\”){id name}}\"}’ --compressed

Windows has issues in curl with double quotes. I have tested also in Linux with single quotes but also I get error.

I have only managed to use Curl well when there are no arguments, e.g. when fetching streams:

curl “https://speckle.xyz/graphql” -H “Accept-Encoding: gzip, deflate, br” -H “Content-Type: application/json” -H “Accept: application/json” -H “Connection: keep-alive” -H “DNT: 1” -H “Origin: https://speckle.xyz” -H “Authorization: Bearer MyBearer” --data-binary “{\“query\”: \“query{user {streams(limit:50) {totalCount items {id name description updatedAt createdAt isPublic role}}}}\”}” --compressed

2 Likes

As long as yourbearer is the real token, then I’m out of ideas here. Maybe @gergo can help? My experience with curl is mostly copy-paste based :grimacing:

1 Like

Hey @Dimitrios.Ververidis,

2 things come to mind:

The first one, that using curl directly in windows is misleading, as it doesn’t call cUrl but Invoke-WebRequest. Not an expert here, but afaik they don’t operate in the same way 100%, so make sure you’re using the right curl :+1:t3:

If you were already using the right curl, i’d suggest trying with a simpler request? I tried with your request (changing the id and bearer) and it didn’t work on my side either. But this stripped down request did (and added variables to the body just for fun :slight_smile: )

curl.exe
 -X 'POST' 'https://speckle.xyz/graphql' 
 -H 'Authorization: Bearer YOUR_TOKEN' 
 -H 'Content-Type: application/json' 
 -d '{\"query\": \"query($streamId:String!){stream(id:$streamId){id name}}\",\"variables\": {\"streamId\": \"YOUR_STREAM_ID\"}}'

Notice that I’m using curl.exe which I installed using chocolatey.
I added new line chars to make it easier to read, this is the one-liner to copy paste:

curl.exe -X 'POST' 'https://speckle.xyz/graphql' -H 'Authorization: Bearer YOUR_TOKEN' -H 'Content-Type: application/json' -d '{\"query\": \"query($streamId:String!){stream(id:$streamId){id name}}\",\"variables\": {\"streamId\": \"YOUR_STREAM_ID\"}}'

Let us know if that does the trick! :slight_smile:

2 Likes

Good catch @AlanRynne I did not know about the curl alias in windows… It works for me with the curl.exe.

Also tested WSL and linux curl, it also works without the character escapes.

1 Like

Ok, i think there might be some character encoding shenanigans going on here. @Dimitrios.Ververidis i’ve copied your example, and the ' and " characters were not the standard unicode chars. Could you check again by copy pasting Alan’s example.

2 Likes

Thanks Alan, the screenshots and the one line code were really helpful.

I have managed to fetch branches of private and public Streams with it!!!

I used Powershell and curl.exe 7.55 (for some reason Powershell didn’t like 7.80 in my “C:\ProgramData\chocolatey\bin”, it was always finding the preinstalled 7.55)

Solution:

curl.exe -X 'POST' 'https://speckle.xyz/graphql' -H 'Authorization: Bearer YOUR_TOKEN' -H 'Content-Type: application/json' -d '{\"query\": \"query($streamId:String!){stream(id:$streamId){id name}}\",\"variables\": {\"streamId\": \"YOUR_STREAM_ID\"}}'

Perhaps it will worth adding this in the CURL button in the GraphQL playground. I think there is little chance for someone to get through to that when the GraphQL query needs one or more arguments.

PS: Windows cmd does not like the single quotes. So it is not working with cmd

2 Likes