How get comments from cells with Google Sheets api - google-sheets-api

How i can get comments using Google sheets api?
fields=sheets/data/rowData/values/note return only notes
For example it's note
note
and it's comment
comment
So how i can get comments?

It's available as the note field in CellData which you can get through spreadsheets.get with the includeGridData parameters set to true

You can list comments using the Google Drive API. Using the spreadsheet ID you can reference the file in Google Drive too.
To list the comments of your spreadsheet call the Comments: list endpoint.
curl \
'https://www.googleapis.com/drive/v3/files/[YOUR_SPREADSHEET_ID]/comments?fields=*&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed

Related

Not able to create ENV variable using API token

I was trying to automate creating ENV variables in CI/CD by using API commands, but unfortunately getting 401 Unauthorized error.
Earlier I used to do this in same way and was able to do it.
But now it’s throwing an error, could anyone please help me to find out.
Command:
curl --request POST --header “PRIVATE-TOKEN: <your_access_token>” \
“https://gitlab.com/api/v4/projects/1/variables” --form “key=NEW_VARIABLE” --form “value=new value”
Please look into the error message:
The "Create a variable" API call indeed looks like:
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
"https://gitlab.com/api/v4/projects/1/variables" --form "key=NEW_VARIABLE" --form "value=new value"
(make sure to use the right double-quotes " instead of “)
Double-check the ID of the project (in your case "1") and make sure the user authenticated with your token has the right permissions:
They must be "maintainer" or "owner", in order to have the right to "Manage project-level CI/CD variables".
Example, using a Personal Access Token with api scope, starting with glpat- (glpat-xxxxxxx), I can first list my projects (using jq):
curl -XGET --header "PRIVATE-TOKEN: glpat-xxxx" "https://gitlab.com/api/v4/projects/owned?=true"|jq ".[] | \"\(.id) \(.path_with_namespace)\""
That allows me to find the project id
I can then list variables for an existing project:
curl -XGET --header "PRIVATE-TOKEN: glpat-xxxx" "https://gitlab.com/api/v4/projects/<projectId>/variables"
Result:
[]
I have none on that project.
I will set one with:
curl -XPOST --header "PRIVATE-TOKEN: glpat-xxxx" "https://gitlab.com/api/v4/projects/<projectId>/variables" --form "key=NEW_VARIABLE" --form "value=new value"
Result:
{"variable_type":"env_var","key":"NEW_VARIABLE","value":"new value","protected":false,"masked":false,"environment_scope":"*"}
Let's double-check with:
curl -XGET --header "PRIVATE-TOKEN: glpat-xxxx" "https://gitlab.com/api/v4/projects/<projectId>/variables"
Result:
[{"variable_type":"env_var","key":"NEW_VARIABLE","value":"new value","protected":false,"masked":false,"environment_scope":"*"}]
It does work.
The OP Anirban Das confirms in the comments an issue with how Postman was used:
Actually in the body of Postman, select 'form', there I had mentioned directly key name in the Key section and value in the Value section.
But that was not correct.
In the Key section, we need to mention "key" and key name should be in Value section.
Similarly "value" in key section and it's value in Value section.
Once this worked, you will see "</>" icon in right navigation pane, which will provide you corresponding curl command

How to create new resource from a file via CKAN API with cURL?

The following cURL is from: https://tech.datopian.com/ckan/play-around.html#create-organizations-datasets-and-resources
and lets you add a resource to a datset from a url.
curl -X POST http://ckan:5000/api/3/action/resource_create -H "Authorization: 9c04a69d-79f4-4b4b-b4e1-f2ac31ed961c" -d '{
"package_id": "my-first-dataset",
"url": "https://raw.githubusercontent.com/frictionlessdata/test-data/master/files/csv/100kb.csv",
"description": "This is the best resource ever!" ,
"name": "brand-new-resource"
}'
Was wondering how you could add a resource from a file.
I can share my example request from a Postman collection (hope it helps):
curl --location --request POST 'http://local-ckan/api/3/action/resource_create' \
--header 'Authorization: xxx-yyy-zzz' \
--form 'package_id="dataset-name"' \
--form 'upload=#"/home/tomek/Downloads/example.csv"' \
--form 'name="new-resource-with-file"'
And here's a note on creating resources from my achives while I was dealing with uploading files to CKAN:
API calls are either POST with a JSON body or POST with a multipart/form body. When using multipart/form you can't nest anything (e.g. resources) in the same call so you have to make multiple calls (package_create, resource_create, resource_create, ...). When using JSON you can't upload files as part of the same call so you need to attach any files with separate multipart/form calls e.g. with resource_patch

How do I use the REST API to update an Apex Trigger?

curl --location --request PUT 'https://ap17.salesforce.com/services/data/v48.0/sobjects/ApexTrigger/01q2x000000YiNcAAK' \
--header 'Authorization: Bearer 00D2....' \
--header 'Content-Type: application/json' \
--data-raw '{
"Name": "ContactCreateUpdateDeleteApexTrigger",
"TableEnumOrId": "Contact",
"Body":"trigger ContactCreateUpdateDeleteApexTrigger on Contact (after update,after insert, after delete) { String url = '\''https:endpoint.com'\''; String content = WebhookClass.jsonContent(Trigger.new, Trigger.old,'\''Contact'\''); WebhookClass.callout(url, content); }"
}'
I am getting 200 Response but my triggers are not updated.
Apex class, Apex trigger tables are visible just for reference purposes and backups. What you do is not a simple data manipulation operation, it has to be a proper deployment with compilation, running unit tests, min 75% code coverage... Especially that your endpoint looks like a production.
Check the Tooling API, it's also RESTful. This should be a nice start: https://salesforce.stackexchange.com/q/156221

Getting "You don't have a required scope to access the endpoint" when inserting script

I'm developing an app, for store fronts and want to get some analytics in checkout. So I want to inject a script in that scope of checkout. When I try to insert it I'm getting "You don't have a required scope to access the endpoint" but I have updated the scopes to checkoutcontent to modify. Not sure what else is wrong
Trying to insert script via an app, getting 403 even though I updated the OAuth scopes to include, Check out content and Checkout
curl --request POST \
--url https://api.bigcommerce.com/stores/{store_hash}/v3/content/scripts \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-auth-client: XXXXX' \
--header 'x-auth-token: XXXXX' \
--data '{"name":"Test Scripts Tag","description":"Test Scripts Tag","html":"<script src=\\\"https://Somedestination/Test.js\\\"></script>","src":"https://Somedestination/Test.js","auto_uninstall":true,"load_method":"default","location":"footer","visibility":"checkout","kind":"src"}'
Getting below error, while expecting a status=200
status: 403,You don't have a required scope to access the endpoint
The html field shouldn't be included when using src, could you try removing it?
The only errors I was receiving in testing were due to malformed HTML in the html field with the error code 422. It may also be worth trying to create a new API account to rule out scoping causing this.

Uber API "POST /requests/estimate" response POST "code":"unauthorized"

i'll try to get data by following API calling:
Uber API -- POST /requests/estimate
curl -X POST \
-H 'Authorization: Bearer JA.VUNmGAAAAAAAEgASAAAABwAIAAwAAAAAAAAAEgAAAAAAAAG8AAAAFAAAAAAADgAQAAQAAAAIAAwAAAAOAAAAkAAAABwAAAAEAAAAEAAAAHK_p1D73ZBrTyH5MuBCGAhsAAAA28z3l42QLSOiQE_6m1J30O4ZQjwpDR_rVf5o41ONOluUZohTYhXEhHNBCLkDO0mXJV39hE2RkcsIRm9ICi_UMVGESeHsQ_uRsX_yD1EDoUbcdHa0Yhf8XGOJkFz1-IB5x9Ivq6SxHpmREeExDAAAAGRcztTG8GDUTlDYpSQAAABiMGQ4NTgwMy0zOGEwLTQyYjMtODA2ZS03YTRjZjhlMTk2ZWU' \
-H 'Accept-Language: en_US' \
-H 'Content-Type: application/json' \
-d '{
"start_latitude": 37.7752278,
"start_longitude": -122.4197513,
"end_latitude": 37.7773228,
"end_longitude": -122.4272052
}' "https://api.uber.com/v1.2/requests/estimate?scope=request
Response
{"code":"unauthorized","message":"This endpoint requires at least one of the following scopes: profile, request, request.delegate, request.delegate.tos_accept, surge_accept"}%
While Below API are working Fine
/products
/estimates/price
/estimates/time
this is old API. New one looks like this.
GET /v1.2/estimates/price