Access denied Error while uploading file to google cloud storage using Apigee API proxy - file-upload

I am getting access denied error while trying to upload a file to google cloud storage using apigee api proxy. here is the error
<HTML>
<HEAD>
<TITLE>Access Denied</TITLE>
</HEAD>
<BODY>
<H1>Access Denied</H1>
You don't have permission to access
"http://dev-apis.ihg.com/ics/libraries/v1/files" on this server.<P>
Reference #18.df2a0660.1669823422.237e2655
</BODY>
</HTML>
Here is the curl I have -
curl --location --request POST 'https://dev-apis.ihg.com/ics/libraries/v1/files' \
--header 'X-IHG-API-KEY: n5AwmgY0sDfjVQA9SIizlgOvYeZunbFp' \
--header 'X-IHG-AGENT-TOKEN: XXXXXXXX \
--header 'SMUSERNAME: XXXXXXX' \
--header 'Cookie: XXXXX' \
--form '=#"TIDW.DAT"' \
--form 'uploadDto="{
\"fileType\":\"TA_Uploads\",
\"fileSubType\":\"TRUE\",
\"supportCaseNbr\":\"9999\",
\"comments\":\"File upload\",
\"requesterName\":\"XXXXX\"
}"'
I have added streaming property for request and response in proxy endpoint as well as target endpoint.
<Properties>
<Property name="response.streaming.enabled">true</Property>
<Property name="request.streaming.enabled">true</Property>
</Properties>
When I tried to run my upload API from local it worked and I was able to upload file in google cloud storage.
When I tried to trace this request in Apigee edge I couldn't see the request landing to get traced. It appears it is failing at Apigee end when it is trying to process the message.
Please help me get over this.

Related

dremio list user API

I'm trying to query dremio using the documented API to get list of users.
Dremio version:
Build
20.2.2-202203241726030461-f7eea3e0
Edition
Enterprise Edition
API:
https://docs.dremio.com/software/rest-api/user/list-users/
sample query:
curl -X GET --location "http://localhost:9047/api/v3/user" \
-H "Authorization: _dremiohrr395nv31g8k610616tucp91g" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
I keep getting this error:
{
"errorMessage": "Something went wrong. Please check the log file for details, see https://docs.dremio.com/advanced-administration/log-files.html",
"moreInfo": "HTTP 405 Method Not Allowed"
}
It seems that this API is not supported at all.
Is there a published API to list all users so that I can get user name, uid, and role memberships?
I'm trying to avoid using SQL query.
v3 list users API is buggy.
user apiv2/user works

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

Watson speech to text authentication

I am trying to get Transcribe from Microphone working on my server as a starting point.
The code is straightforward but I am having trouble with the token.
on IBMcloud I created a IAM-Service id with Access Policies
Viewer, Reader 14 Speech to Text service in all resource groups
created an apikey from that
created the token file
curl -k -X POST --output token \
--header "Content-Type: application/x-www-form-urlencoded" \
--header "Accept: application/json" \
--data-urlencode "grant_type=urn:ibm:params:oauth:grant-type:apikey" \
--data-urlencode "apikey={apikey}" \
"https://iam.cloud.ibm.com/identity/token"
the response has 'access_token' but the javascript SDK 0.38.1 looks for 'accessToken'
when I start microphone I get a socket error 'wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize"
I checked token expiration.
I confirmed it is an auth problem:
curl -X GET "https://stream.watsonplatform.net/speech-to-text/api/v1/models?access_token="{accessToken}"
responds "unauthorized"
I have researched and am unsure what to do next. My best guess is I am generating the token improperly.
I would leave the token generation to the code. All the SDKs have an IAMAuthenticator component. The full documentation for Node.js is here. It has a very simple example where you pass in the API key:
import { IamAuthenticator } from 'ibm-cloud-sdk-core';
const authenticator = new IamAuthenticator({
apikey: '{apikey}',
});
Thereafter, you instantiate the service, e.g., STT.

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.

Can't find out base GitLab API base url

I've created project and repo on my gitlab.com account, generated private key, now I'm trying to do api call to get list of commits.
Now I want to get list of projects via api, from documentation
https://docs.gitlab.com/ce/api/projects.html#list-projects
GET /projects
So I'm doing
curl --header "PRIVATE-TOKEN: XXXXXXX -c" "https://gitlab.com/projects"
And getting 404.
I've tried several combinations and can't find correct base url.
Same for repository commits, documentations https://docs.gitlab.com/ce/api/commits.html says
https://gitlab.example.com/api/v3/projects/5/repository/commits
fine, I'm trying (with myusername/projectname as project id)
https://gitlab.com/api/v3/projects/myusername/projectname/repository/commits
And got 404 as well
The correct base url for the hosted GitLab is https://gitlab.com/api/v4/ so your request to
GET /projects would be
curl --header "PRIVATE-TOKEN: XXXXXX" "https://gitlab.com/api/v4/projects"
That would return all projects that are visible to you, including other user's public projects.
If you wish to view just your projects, then you should use the GET /users/:user_id/projects endpoint, where :user_id is your user ID that can be found on your GitLab profile page or in the response to your request to GET /user if you're authenticated.
# Get :user_id from this request
curl --header "PRIVATE-TOKEN: XXXXXX" "https://gitlab.com/api/v4/user"
# See your projects by replacing :user_id with id value from previous request
curl --header "PRIVATE-TOKEN: XXXXXX" "https://gitlab.com/api/v4/users/:user_id/projects"
Also, the project ID is not the same as the project name. You can retrieve the project ID from the response of your request to GET /users/:user_id/projects, or from the project's settings page.
For me the following request worked:
curl --header "PRIVATE-TOKEN: YOUR_TOKEN" "https://gitlab.com/api/v4/users/YOUR_USER_ID/projects"
Don't know why the request :curl --header "PRIVATE-TOKEN: PRIVATE_TOKEN" "https://gitlab.com/api/v4/projects/" returned a list with some other public projects.
Another useful request for user info: curl --header "PRIVATE-TOKEN: PRIVATE_TOKEN" "https://gitlab.com/api/v4/user/"
https://docs.gitlab.com/ee/api/#basic-usage
try this command : curl "https://gitlab.example.com/api/v4/projects"
as given in the document
If you are using version3 of Gitlab
then use
curl --header "Authorization: Bearer OAUTH-TOKEN" https://gitlab.example.com/api/v3/projects
There is also "python-gitlab" module which will help you get Id from Project-name easily
https://python-gitlab.readthedocs.io/en/stable/