How to include my user as a member in a Group type identity in Sandbox? - api

In Sandbox, the logged-in user needs to be a member of a group to register data products or apps.
How can I add my user to a group?

You, as user, are an identity of type Person. A Group is also a type of identity in Platform of Trust.
A Person must be linked to a Group with MemberOf type of link.
Using Identity API, you can create a Group type identity and connect your own user identity to the group with a MemberOf type link.
To create a group, run the following cURL command:
curl -i -X POST \
-H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9eyJzY29w...DVs5aaf" \
-H "Content-Type: application/json" \
-d \
"{
"context": "https://standards.oftrust.net/v2/Context/Identity/Group/",
"type": "Group",
"data": {
"name": "Company Oy"
}
}" "https://api-sandbox.oftrust.net/identities/v1"
On Success, you'll get the following response including the ID of the created group.
Next, you need to link your user identity to the created group identity with a MemberOf type link.
option1: This post in StackOverflow discusses how to obtain the current logged-in user's ID.
OR,
option2:
Start with getting your user ID (you need to be logged-in into the Sandbox) using /me end
point of Login API
Request:
curl -i -X GET \
-H "Authorization: Bearer eyJ0eXAi...hdEsJLNGV2YA" \
"https://api-sandbox.oftrust.net/me"
Response:
HTTP/1.0 200
{
"#context": "https://standards.oftrust.net/v2/Context/Identity/LegalParty/Person/",
"#type": "Person",
"#id": "33237067-14c3-4801-9e50-bf08406406e2",
"email": "user#example.com",
"role": "developer",
"firstName": "Anna",
"lastName": "Bar"
}
Then make a POST request to Identity API with Identity IDs of your user and the created group as parameters:
curl -i --request POST \
--url https://api-sandbox.oftrust.net/identities/v1/{fromIdentityId}/link/{toIdentityId} \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9eyJzY29w...DVs5aaf' \
--header 'content-type: application/json' \
--data '{
"context": "https://standards.oftrust.net/v2/Context/Link/Role/MemberOf/",
"type": "MemberOf"
}'
Remember to set the parameters as the following:
fromIdentityId = ID of your own user
toIdentityID = ID of the created group above.
On success, you should receive the following response:
HTTP/1.0 201
{
"#context": "https://standards.oftrust.net/v2/Context/Link/Role/MemberOf/",
"#type": "MemberOf",
"#id": "be7a2c57-03d8-46f4-aaf0-2b1ca118ef5c",
"from": "8ac7494b-b7bc-4a63-a253-4b9b1887b262",
"to": "a6b5a74e-bd98-4c9b-9561-932877258833",
"data": {},
"metadata": {
"createdAt": "2019-09-12T09:49:24+00:00",
"createdBy": "33237067-e72c-4f26-b78b-9f9e234b2e7d",
"updatedAt": "2019-09-12T09:49:24+00:00",
"updatedBy": "33237067-e72c-4f26-b78b-9f9e234b2e7d"
}
}
Now you will bee able to use the created group to register data products and apps in Platform of Trust.
Alternatively, you can use world-sandbox.oftrust.net to create your group identity using the UI. Simply save the group ID that appears in the S-alert.
Checkout Identity API documentation here.
You can also use our Insomnia Workspace and Guide to execute chain request to create a Group.

Related

How do you specify the sourceBranch for a Run of Pipelines via the REST API?

I've been trying to run a pipeline for a particular branch of the repository I'm using.
In the UI, there is a convenient option, but I don't understand what to try in the request.
No matter what I do I always run from master.
How do I change that? I tried filling out the repository parameters but to no avail: https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/run%20pipeline?view=azure-devops-rest-6.0#repositoryresourceparameters
Here is an example request:
curl --location --request POST 'https://dev.azure.com/<redacted>/<redacted>/_apis/pipelines/<redacted>/runs?api-version=6.0-preview.1' \
--header 'Authorization: Basic <redacted>' \
--header 'Content-Type: application/json' \
--header 'Cookie: VstsSession=<redacted>' \
--data-raw '{
"previewRun": true,
"resources": {
"repositories": {
"refName": "refs/heads/<redacted>"
}
},
"runParameters":
{
"namespace" : "<redacted>",
"image" : "<redacted>",
"tag" : "<redacted>",
"package" : "<redacted>",
"version" : "8.4.4"
}
}'
From your screenshot, it seems that you are using the YAML pipeline.
I have tested your example , and the root cause of this issue is that the request body(data-raw) has some issues.
You could try my sample
curl --location --request POST 'https://dev.azure.com/<redacted>/<redacted>/_apis/pipelines/<redacted>/runs?api-version=6.0-preview.1' \
--header 'Authorization: Basic <redacted>' \
--header 'Content-Type: application/json' \
--header 'Cookie: VstsSession=<redacted>' \
--data-raw '{
"stagesToSkip":[],
"resources":
{
"repositories":
{
"self":{"refName":"refs/heads/{Branchname}"}
}
},
"templateParameters":
{
"namespace":"{value}",
"image":"{value}",
"tag":"{value}",
"package":"{value}",
"version":"{value}"
},
"variables":{}
}'
Result:
For Http Request (you can test it with Postman)
1. Get pipeline api url like this
https://dev.azure.com/{organization}/{project}/_apis/pipelines/{pipelineId}/runs?api-version=7.1-preview.1
Source: https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/run-pipeline?view=azure-devops-rest-7.1
Fill in your organization, project and pipelineId.
(all of this can be found in the link when you open your pipeline definition in Azure DevOps)
2. Add Basic Auth headers
key: Authorization, value:"Basic [your azure Person Access Token from Azure Dev Ops with Access to Pipeline goes here]"
Should look like this
"Basic OndzNWdz43FKfjdi98hjKDJFH8kkg9854HJKHF9D8RFEHui4387lkNXE="
And set content type to application/json
like this
key: Content-Type, value: application/json
3. Put this JSON Into Raw Body
{
"templateParameters":{
"inputName":"johnsmith"
},
"resources":{
"repositories":{
"self":{
"refName":"refs/heads/feature/#JIRATask01_Blabla"
}
}
},
"variables":{
}
}
Replace refName value with branch you want to run the pipeline for.
If you have multiple repo pipeline look into this topic (but i haven't tested that solution):
Azure DevOps API to Trigger Multi Repo changing branches

Google shopping api Request had insufficient authentication scopes

I make a request to Google shopping by curl:
curl --request POST \
'https://shoppingcontent.googleapis.com/content/v2.1/products/batch?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"entries":[]}' \
--compressed
and the response is
{
"error": {
"code": 403,
"message": "Request had insufficient authentication scopes.",
"errors": [
{
"message": "Insufficient Permission",
"domain": "global",
"reason": "insufficientPermissions"
}
],
"status": "PERMISSION_DENIED"
}
}
I'm sure my access_token is right, but I'm not sure if my API_KEY is right.
My API_KEY is gotten in https://console.cloud.google.com/apis/credentials , and the API_KEY's restrictions is none.
And my Content API for Shopping is enabled:
I wonder if I miss any critical method, that I can't request the api successfully.
By the way, how can I get my merchant_id? Is it my merchant_id?
But the method "Verify and claim your website URL in Business information", I didn't pass. Does it cause to the 403 error?

About Amazon Advertising Api

I applied for the use of the Amazon advertising API, but when I created a security profile in the console, I could use the advertising API of the North American station but not the European station. Do I need to resubmit the application form? url returns an unknown scope
You should use Amazon-Advertising-API-Scope header value which is tied to the EU seller or vendor account.
Use profile endpoint and fetch all profiles which are tied to your current token.
curl --location --request GET 'https://advertising-api.amazon.com/v2/profiles' \
--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxxxxxxxxxxxxxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer Atza|xxxxxxxxx'
Response:
{
"profileId": 390000000000000000,
"countryCode": "US",
"currencyCode": "USD",
"dailyBudget": 0.0,
"timezone": "America/Los_Angeles",
"accountInfo": {
"marketplaceStringId": "AXXXXXXXXXXX",
"id": "BXXXXXXXXXXXX",
"type": "seller"
}
},
You can see NA(North America) profiles(marketplaces) using this request above. In order to retrieve the EU or FE region profiles(marketplaces), Change the API endpoint.
EU = https://advertising-api-eu.amazon.com/v2/profiles
FE = https://advertising-api-fe.amazon.com/v2/profiles
Use profileId property in Amazon-Advertising-API-Scope header(This header is required. see documentation) for all API requests.

Insert Multiple records in BigQuery using WSO2

I am using BigQuery Connector in WSO2 to insert multiple records in BigQuery cloud.
I followed this link and was able to insert a single record successfully.
First I tried to pass multiple records by separating them using a comma.
However, in this case, only the first record gets inserted and other records are skipped.
Please note that no error is returned in this case.
My Json message with multiple records:
{"insertId":"101","json":{"NAME":"Vishal_101","ADDRESS":"UK","ID":"vbordia"}},{"insertId":"102","json":{"NAME":"Vishal_102","ADDRESS":"UK","ID":"vbordia"}}
Second I tried this link which explain how to build multiple records.
However, this time I get an invalid response from BigQuery. Since the response message is not well explanatory I am unable to understand the cause.-
Messagean :
{
"rows":
[
{
"insertId":"209",
"json":
{
"NAME": "NewRow1",
"ADDRESS": "NewAddr",
"ID": "123"
}
},
{
"insertId":"210",
"json":
{
"NAME": "NewRow2",
"ADDRESS": "NewAddr",
"ID": "123"
}
}
]
}
Error Message Returned from BigQuery :
{
"insertErrors": [
{
"index": 0,
"errors": [
{
"reason": "invalid",
"location": "",
"debugInfo": "",
"message": ""
}
]
}
]
}
Can anyone please help me here.What is the correct way of inserting multiple records in BigQuery via Wso2.
Thanks in advance.
This was a bug in WSO2 Bigquery connector. We have raised with WSO2 and they have now released new version of connector which is capable of inserting multiple records.You can find the latest version at WSO2 market place.
Based on your data I created a test table in my project
And used the API to upload your example data as follow:
curl --request POST \
'https://www.googleapis.com/bigquery/v2/projects/myproject/datasets/dataset/tables/testInsert/insertAll' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"rows":[{"insertId":"z1","json":{"NAME":"Vishal_z1","ADDRESS":"UK","ID":"vbordia"}},{"insertId":"z2","json":{"NAME":"Vishal_z2","ADDRESS":"UK","ID":"vbordia1"}}]}' \
--compressed
using this SELECT:
SELECT * FROM `project.dataset.testInsert` LIMIT 1000
I confirmed the data is in the table:

CouchDB replication - Unauthorized to access or create database

I am trying to setup a CouchDB database replication but both is not working via Futon and cURL/CLI: It ends up with the following error message in both cases:
{"error":"unauthorized","reason":"unauthorized to access or create database table1"}
curl -X POST http://127.0.0.1:5984/_replicate -d '{"source": "table1",
"user_ctx": {"name": "", "roles": ["admin"]}, "target":
"http://username:password#server:5984/table1", "create_target": false,
"continuous": true}' -H "Content-Type: application/json"
The target database is secured via a username and password and for HTTP basic authentication i added the credentials as you can see. The same error appears when i create a replication document via Futon.
Thanks for your help.
It is a little bit late but I think you need it.
(CouchDb 1.6.1)
https://wiki.apache.org/couchdb/Replication
POST /_replicate HTTP/1.1
{
"source": {
"url":"https://example.net:5984/table1",
"headers":{
"Authorization":"Basic Ym9iQGV4YW1wbGUuY29tOnBhc3N3b3Jk"
}
},
"target":"target1",
"create_target": false,
"continuous": true
}
where the base64 string following the word "Basic" is the output of:
echo -n 'username:password' | base64 (username and password for database table1 in https://example.net:5984.
Very important : when you send your request you send it to an url. The target should also be the name of the database where you will replicated "target":"http://server:5984/table1" -->> table1
The request header you use to send this replication should contains the Basic token too. (a admin username and password or the superadmin password of the target database)
Resume
curl -X POST http://127.0.0.1:5984/_replicate
-d '{
"source": {
"url":"https://example.net:5984/table1",
"headers":{
"Authorization":"Basic Ym9iQGV4YW1wbGUuY29tOnBhc3N3b3Jk"
}
},
"target":"target1",
"create_target": false,
"continuous": true
}' -H "Authorization: Basic dXNlcm5hbWUyOnBhc3N3b3JkMg==;Content-Type: application/json"
dXNlcm5hbWUyOnBhc3N3b3JkMg== : username2:password2 (base64)
Ym9iQGV4YW1wbGUuY29tOnBhc3N3b3Jk : username:password (base64)
username2:password2 : admin name and password of the database target1 (on http://server:5984)
username:password : admin name and password of the database target1 (on 127.0.0.1:5984)