Closed krosoftware closed 6 years ago
Hello,
You are doing everything correctly, the problem is your bucket name. I'm almost 99% sure someone else already used that name. Bucket names are universal and they must be unique in order to work try something more unique for your bucket, you can generate a random guid and concatenate it with your bucket name. "test "or in this case "apptestbucket" are not very unique.
Good luck! Cheers,
@krosoftware, additionally on what @jaimerosales mentioned, please make sure to use bucket:create
scope, the CURL you posted is using code:all
see POST Buckets documentation at https://forge.autodesk.com/en/docs/data/v2/reference/http/buckets-POST/
Hello thank you for your help. I changed bucket name and used is bucket:create instead of code:all. Now my commandline looks like this: curl -k -v "https://developer.api.autodesk.com/oss/v2/buckets" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6Imp3dF9zeW1tZXRyaWNfa2V5In0.eyJjbGllbnRfaWQiOiJ1OXc4b2NYc3Y3dm96Rm9PQWVjakhGckZwRmN6cmZBbiIsImV4cCI6MTUzNTc5NTgwNywic2NvcGUiOlsiYnVja2V0OmNyZWF0ZSJdLCJhdWQiOiJodHRwczovL2F1dG9kZXNrLmNvbS9hdWQvand0ZXhwNjAiLCJqdGkiOiJZQmtnWUVidGlOekttZXhueXRYNXpLVTF6MFNrd2lMcXlIR3lNRWl5SlZUTUV5Q2NrYXBmRk1Lek1GVVF6OU43In0.rLY1hAQxtzmEoM2OlYNuwbLkTaPceBEU0-ssEs068-0" --data "bucketKey=gala_apptestbucket&policyKey=transient" --header "Content-Type: application/json"
and here is complete command and response:
curl.exe -k -v "https://developer.api.autodesk.com/oss/v2/buckets" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6Imp3dF9zeW1tZXRyaWNfa2V5In0.eyJjbGllbnRfaWQiOiJ1OXc4b2NYc3Y3dm96Rm9PQWVjakhGckZwRmN6cmZBbiIsImV4cCI6MTUzNTc5NTgwNywic2NvcGUiOlsiYnVja2V0OmNyZWF0ZSJdLCJhdWQiOiJodHRwczovL2F1dG9kZXNrLmNvbS9hdWQvand0ZXhwNjAiLCJqdGkiOiJZQmtnWUVidGlOekttZXhueXRYNXpLVTF6MFNrd2lMcXlIR3lNRWl5SlZUTUV5Q2NrYXBmRk1Lek1GVVF6OU43In0.rLY1hAQxtzmEoM2OlYNuwbLkTaPceBEU0-ssEs068-0" --data "bucketKey=gala_apptestbucket&policyKey=transient" --header "Content-Type: application/json"
POST /oss/v2/buckets HTTP/1.1 Host: developer.api.autodesk.com User-Agent: curl/7.61.0 Accept: / Authorization: Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6Imp3dF9zeW1tZXRyaWNfa2V5In0.eyJjbGllbnRfaWQiOiJ1OXc4b2NYc3Y3dm96Rm9PQWVjakhGckZwRmN6cmZBbiIsImV4cCI6MTUzNTc5NTgwNywic2NvcGUiOlsiYnVja2V0OmNyZWF0ZSJdLCJhdWQiOiJodHRwczovL2F1dG9kZXNrLmNvbS9hdWQvand0ZXhwNjAiLCJqdGkiOiJZQmtnWUVidGlOekttZXhueXRYNXpLVTF6MFNrd2lMcXlIR3lNRWl5SlZUTUV5Q2NrYXBmRk1Lek1GVVF6OU43In0.rLY1hAQxtzmEoM2OlYNuwbLkTaPceBEU0-ssEs068-0 Content-Type: application/json Content-Length: 48
what can be wrong? Thank you for your help.
Hey,
I see you are trying to do the whole cURL workflow to upload, translate a file. I created a tutorial a while back which should help you with this.
https://forge.autodesk.com/blog/tutorial-using-curl-2-legged-authentication-model-translation
Cheers!
Adding to what @jaimerosales said, the body
should be in JSON format, so something like:
{'bucketKey':'gala_apptestbucket', 'policyKey': 'transient'}
Thank you both but it does not work for me :( I'm currently on step 2 (creating bucket) and here is content my Windows "create_bucket.bat" file:
curl -k -v "https://developer.api.autodesk.com/oss/v2/buckets" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6Imp3dF9zeW1tZXRyaWNfa2V5In0.eyJjbGllbnRfaWQiOiJ1OXc4b2NYc3Y3dm96Rm9PQWVjakhGckZwRmN6cmZBbiIsImV4cCI6MTUzNjA0OTQ5Nywic2NvcGUiOlsiZGF0YTpyZWFkIiwiZGF0YTp3cml0ZSIsImJ1Y2tldDpjcmVhdGUiLCJidWNrZXQ6cmVhZCIsImRhdGE6Y3JlYXRlIiwiYWNjb3VudDpyZWFkIiwiYWNjb3VudDp3cml0ZSJdLCJhdWQiOiJodHRwczovL2F1dG9kZXNrLmNvbS9hdWQvand0ZXhwNjAiLCJqdGkiOiIyS2MxZGM4YTVqTkdBVWgwQXBWS0hKdTVxZmNWZmlHT2szcm1vVlBWeTdPT1BhVVRwa2lIREJBcGRsa20zZDU1In0.FJ7Xs0EiOW7aLjXmB1CR6A99syzsuOZXjrFKw5jSk4E" --data '{"bucketKey":"forge-blog-post123abc", "policyKey":"transient"}' --header "Content-Type: application/json"
and here is error code:
{"reason":"Unable to parse JSON"}* Connection #0 to host developer.api.autodesk.com left intact curl: (3) [globbing] unmatched close brace/bracket in column 20
@jaimerosales , as I can see in your step 2, you are using very short string after "Bearer" and my string is very large.. why is that?
Can anybody try to use Windows version of curl to test my examples, please?
Here is content of my auth.bat file:
curl https://developer.api.autodesk.com/authentication/v1/authenticate --data "client_id=myID&client_secret=mySECRET&grant_type=client_credentials&scope=data:read data:write bucket:create bucket:read data:create account:read account:write" --header "Content-Type:application/x-www-form-urlencoded" -k
after I received access_token, I put them into "create_bucket.bat" file (see above) and after I execute create_bucket.bat, I'm receiving error.
@jaimerosales , I just want to follow your steps but using WIndows curl version so I want to create 6 BAT files and now I can not pass step 2 so please if someone see this and use Windows, please tell me what I'm doing wrong. Thank you.
Can anybody help, please? Or, is there complete working example which uploads file and preview it in viewer? Thank you.
@krosoftware this is not a monitored support channel, so may take more time... best is to use stackoverflow (autodesk-forge
tag)
in this case, Windows needs \" instead, so try with:
"curl.exe" -k -v "https://developer.api.autodesk.com/oss/v2/buckets" -X POST -H "Content-Type: application/json" -H "Authorization: Bearer abcd1234" -d "{\"bucketKey\":\"apptestbucket\", \"policyKey\":\"transient\"}"
Awesome, thank you so much for your help, creating bucket works, now I'm going to next steps.
Hello I have problem by creating a bucket. I'm using Windows curl.exe for testing and here is command-line for authentication:
curl -k https://developer.api.autodesk.com/authentication/v1/authenticate --data "client_id=myId&client_secret=mySecret&grant_type=client_credentials&scope=code:all" --header "Content-Type:application/x-www-form-urlencoded"
returned is access_token and then I'm using:
curl.exe -k -v "https://developer.api.autodesk.com/oss/v2/buckets" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6Imp3dF9zeW1tZXRyaWNfa2V5In0.eyJjbGllbnRfaWQiOiJ1OXc4b2NYc3Y3dm96Rm9PQWVjakhGckZwRmN6cmZBbiIsImV4cCI6MTUzNTcxMjAwNCwic2NvcGUiOlsiZGF0YTpyZWFkIl0sImF1ZCI6Imh0dHBzOi8vYXV0b2Rlc2suY29tL2F1ZC9qd3RleHA2MCIsImp0aSI6ImYyQ3hvQ3hLZkN6WDYzbjd0RkJkcEZKZHNDYTA4cUx3T1MzYThwTTkwTmVOTXBQSUNhVDlYUTBTc3Bmemo0WjYifQ.Srhxx3S3phcsUHEQmho_2r_K4cQ-G5P9XxLeXkA0MWg" --data "bucketKey=apptestbucket&policyKey=transient"
and here is what it returns: "Token does not have the privilege for this request.* Connection #0 to host developer.api.autodesk.com left intact"
How to solve that, please?