Printful Oauth Api Prod. Upload - api

Description:
Oki, i am trying to upload products to printful via api
|> __ they changed to oauth and the docs are not matching anymore
|> __ the functionality itself is in their docs, but i cant get it to auth
|> __ their dev support was not helpful and i am not a api person
Assets:
=>> https://developers.printful.com/docs/#section/Products-API-examples/Create-a-new-Sync-Product
=>> https://developers.printful.com/docs/#operation/createSyncProduct
Code:
heres my error and code basically directly from their docs:
{"code":200,"result":"Welcome to the Printful API","extra":[]}
{"code":400,"result":"This API endpoint applies only to Printful stores based on the
Manual Order / API platform.
Find out more at Printful API docs.","error":{"reason":"BadRequest","message":
"This API endpoint applies only to Printful stores based on the Manual Order
/ API platform. Find out more at Printful API docs."}}%
# Authorized CURL request with Basic auth
curl -X GET 'https://api.printful.com/' \
-H 'Authorization: Bearer TOKEN'
curl --location --request POST 'https://api.printful.com/store/products' \
-H 'Authorization: Bearer SAMEtOKEN' \
--data-raw '{
"sync_product": {
"name": "T-Shirt",
"thumbnail": "https://picsum.photos/200/300"
},
"sync_variants": [
{
"retail_price": 21.00,
"variant_id": 4011,
"files": [
{
"url": "https://picsum.photos/200/300?image=1"
},
{
"type": "back",
"url": "https://picsum.photos/200/300?image=1"
}
]
},
{
"retail_price": 21.00,
"variant_id": 4012,
"files": [
{
"url": "https://picsum.photos/200/300?image=1"
},
{
"type": "back",
"url": "https://picsum.photos/200/300?image=1"
}
]
}
]
}'

To save anyone else the headache:
The Printful 'Create Product' and similiar API calls don't work with shops created via the automatic API integrations:
As far as I'm aware there is no workaround, but if I find one I'll update here. The name is a bit misleading, as the 'Sync Products' seem to describe products capable of syncing with external services. However you are limited to the ECommerce Platform Sync API calls. It seems to be possible to modify an existing one, but that doesn't help much for GUI-free automation.
Maybe you can you create a number of placeholders as 'Drafts' and modify, but haven't gotten that running myself yet.

Related

How can assign permission to user for specific folder in nuxeo using rest api

I upload many files to Nuxeo server using rest API. Now I need to add permission to users. I use http://localhost:8080/nuxeo/api/v1/id/file-id/#acl endpoint with payload:
{
"username": "username",
"permission": "ReadWrite"
}
But it is not working. The error is:
{
"entity-type": "exception",
"status": 405,
"message": "javax.ws.rs.WebApplicationException"
}
How can I do it? Is there any endpoint for that?
Permission can be added by the Document.AddPermission operation available on the http://localhost:8080/nuxeo/api/v1/automation/Document.AddPermission endpoint.
Here is a curl example call used to add ReadWrite permission for editor user to the document with ID 2d28e87f-0753-4cfc-9f9b-b17d424aa6a7:
curl -X POST -u Administrator:Administrator \
http://localhost:8080/nuxeo/api/v1/automation/Document.AddPermission \
-H "Content-Type: application/json" \
-d '{"params":{"users":["editor"],"permission":"ReadWrite"},"input":"2d28e87f-0753-4cfc-9f9b-b17d424aa6a7"}'
And here is an example payload when you want to add permission for external user:
{
"params": {
"users":[],
"email": "some-external#user.com",
"permission": "Read",
"begin": "2020-06-01T00:00:00+02:00",
"end": "2020-06-30T00:00:00+02:00",
"notify": true,
"comment": "notify#me.com"},
"context": {},
"input": "2d28e87f-0753-4cfc-9f9b-b17d424aa6a7"
}

What is the supossed scope for translating file format to SFV?

Im going along with the tutorial from:
https://forge.autodesk.com/en/docs/model-derivative/v2/tutorials/prepare-file-for-viewer/
and i got stuck with translating the file to SVF. I've tried data:write, data:create, bucket:update scopes but each time I get:
Token does not have the privilege for this request.
{
"input": {
"urn": "someUrn="
},
"output": {
"formats": [
{
"type": "svf",
"views": [
"2d",
"3d"
]
}
]
}
}
You will need both data:read and (data:write or data:create) (delimited by space) - see doc here:
curl -v 'https://developer.api.autodesk.com/authentication/v1/authenticate'
-X 'POST'
-H 'Content-Type: application/x-www-form-urlencoded'
-d '
client_id=obQDn8P0GanGFQha4ngKKVWcxwyvFAGE&
client_secret=eUruM8HRyc7BAQ1e&
grant_type=client_credentials&
scope=data:read%20data:write
'
And did you select Model Derivative API when creating the Forge app - if not, start over and create the app again:
Thanks,
I've run also with some different translation errors, but it turns out .rfa files are not supported in the Model Derivative API.
But all in all it worked out

BIM 360 and the Revit API

Im trying to learn more about the Revit API as it works with BIM 360. I know I can determine isCloudInModel (which is available in the 2019 API, not the 2018 - and hopefully its available intentionally this time) and get the path using these strategies https://forums.autodesk.com/t5/revit-api-forum/determine-central-file-type-file-server-our-cloud/td-p/6506907 .
BIM 360 models don't seem to subscribe to Sync events, Im struggling to understand if I can subscribe to any events that have to do with synchronization, saving, opening or anything else.
Is there a reference for API and Limitations of models that are hosted on BIM 360?
Through the Application/ControlledApplication classes you have methods for this. You just need to have the logic for seeing if the application that is triggering the DocumentSynchronizing, DocumentSaving type Events is a BIM360 model. Which you can do with how you find the path.
With the Forge API, through the Data Management API, you can use the PostModelJob endpoint which has this functionality:
Every time you synchronize the current model with the central model, it sets the data attribute to null. When you publish the latest version to BIM 360 Docs (using the PublishModel command), it sets the status to processing or complete.
This will give you the information on if the model has been synced. You also have to be using BIM 360 Docs and not BIM 360 Team.
Successful Retrieval of C4R Publish Status - Model Needs Publishing (200)
Note that if you have updated the central model, the data attribute is set to null until you publish it.
Request
curl -X POST -v "https://developer.api.autodesk.com/data/v1/projects/b.project.id.xyz/commands/" -H "Authorization: Bearer kEnG562yz5bhE9igXf2YTcZ2bu0z" -H "Content-Type: application/vnd.api+json" -d '
{
"jsonapi": {
"version": "1.0"
},
"data": {
"type": "commands",
"attributes": {
"extension": {
"type": "commands:autodesk.bim360:C4RModelGetPublishJob",
"version": "1.0.0"
}
},
"relationships": {
"resources": {
"data": [ { "type": "items", "id": "urn:adsk.wip:dm.file:hC6k4hndRWaeIVhIjvHu8w" } ]
}
}
}
}'
Show Less
Response
{
"data": null
"jsonapi": {
"version": "1.0"
}
}

How to send result in survey monkey using CURL

I create a new survey form using survey monkey, and i get all questions using api and create custom form in my site. Now how can we update the result in survey monkey using CURL. I tired this /surveys/{id}/pages/{id}/questions/{id} but no response.
Version : V3
By "update the result" I presume you mean you want to create a new response for your survey.
You can do that with the response API. There is cURL examples on the right side of the page. Something along the lines of:
curl -i -X POST https://api.surveymonkey.net/v3/collectors/{collector_id}/responses \
-H "Content-Type: application/json" -H "Authorization:bearer <your_access_token>" \
-d '{
"pages": [{
"id": "<page_id>",
"questions": [{
"answers": [{
"choice_id": "<choice_id>"
}],
"id": "<question_id>"
}, {
"answers": [{
"text": "<open ended response>"
}],
"id": "<question_id>"
}]
}]
}'
Depending on the question types you have in your survey. Make sure you have a collector created already.
Given you are just trying to embed a survey on your website, I recommend you just use a website collector instead of trying to automate this yourself (depending on your use case).

GitHub API File Update : "Not Found"

I am attempting to update a file in one of my repos via the API.
Here is my get of that file (works nicely):
curl -XGET 'https://git.fake.local/api/v3/repos/jsmith/repo_version/contents/version.html?ref=gh-pages'
{
"name": "version.html",
"path": "version.html",
"sha": "b1b716105590454bfc4c0247f193a04088f39c7f",
"size": 5,
"url": "https://git.fake.local/api/v3/repos/jsmith/post_version/contents/version.html?ref=gh-pages",
"html_url": "https://git.fake.local/jsmith/post_version/blob/gh-pages/version.html",
"git_url": "https://git.fake.local/api/v3/repos/jsmith/post_version/git/blobs/b1b716105590454bfc4c0247f193a04088f39c7f",
"type": "file",
"content": "aW5pdAo=\n",
"encoding": "base64",
"_links": {
...
}
}
Here is my attempt to update that file via PUT:
curl -XPUT 'https://git.fake.local/api/v3/repos/jsmith/repo_version/contents/version.html?ref=gh-pages' -d '{
"message": "update from api",
"committer": {
"name": "Joe Smith",
"email": "jsmith#fake.com"
},
"content": "bXkgdXBkYXRlZCBmaWxlIGNvbnRlbnRz",
"sha": "b1b716105590454bfc4c0247f193a04088f39c7f"
}'
RESULT:
{
"message": "Not Found"
}
Okay... I think I got it.
From the github doco:
Authentication
There are three ways to authenticate through GitHub API v3. Requests
that require authentication will return 404 Not Found, instead
of 403 Forbidden, in some places. This is to prevent the
accidental leakage of private repositories to unauthorized users.
I was expecting a 403 if Auth was a problem but they are throwing a 404, so basically I probably need to make sure I am auth'd correctly and all will be well.
SOLVED:
I created a personal oauth token (under settings/applications) and add to curl request in header and it all works great.
curl -XPUT -H "Authorization: token MYSECRETTOKEN"