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:
Related
I am building a Calendar Syncing solution in FileMaker using the Google API
I can add and update events to my selected calendar just fine. Using the INSERT URL:
“https://www.googleapis.com/calendar/v3/calendars/" & $calendar & "/events?access_token="& $accessToken”
and
Curl:
"-X POST
-H \"Content-type: application/json\"
--data " & Quote ( $data )
Now I am trying to PULL a LIST of all Events from a specific calendar using:
https://www.googleapis.com/calendar/v3/calendars/{CalendarID}/events?key={APIKEY}
Now I am trying to PULL a LIST of all Events from a specific calendar using the INSERT URL::
https://www.googleapis.com/calendar/v3/calendars/{CalendarID}/events?key={APIKEY}
CURL
"-X GET
--header 'Accept: application/json'\
In response I get:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
Clearly there is something wrong my query, but despite my best efforts reading the google reference material the answer eludes me. I am new to using API's so any suggestions would be most appreciated
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
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.
Using v2 of the API via: http://gdata.youtube.com/schemas/2007/categories.cat, I can see both assignable and deprecated video categories.
However, using the v3 google data API, I see all categories, but no flag indicating if they are usable as a category on a video upload. Case in point is the category labelled "Anime/Animation" (category 31). If you try to upload a video using this category, you will receive a "Bad Request" response from YT at the end of the upload process.
If you choose any of the categories in the "assignable" list as per the first URL, then the upload works. Here's a deprecated category using the Atom based API:
<atom:category term="Movies_anime_animation" label="Anime/Animation" xml:lang="en-US">
<yt:deprecated/>
</atom:category>
Here's the same thing, in JSON, from the Google API Explorer:
{
"id": "31",
"kind": "youtube#videoCategory",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/-p_eJg3ji5PiNMcZrzS4hNfl4gQ\"",
"snippet": {
"channelId": "UCBR8-60-B28hp2BmDPdntcQ",
"title": "Anime/Animation"
}
I've looked at the video.list v3 API docs, and also the raw JSON output from the same API. I can't see how I could differentiate between deprecated and assignable categories. Is this just plain missing from the API or have I missed something?
You can receive the list of assignable categories parsing XML document. This is an example on PHP:
$catURL = 'http://gdata.youtube.com/schemas/2007/categories.cat';
$cxml = simplexml_load_file($catURL);
$cxml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom');
$result = $cxml->xpath('//atom:category/yt:assignable/..');
$categories = array();
foreach ($result as $row) $categories[(string)$row['term']] = (string)$row['label'];
For anyone who stumbles upon this question: YouTube V3 API now returns an assignable flag with each category snippet.
Request
curl \
'https://www.googleapis.com/youtube/v3/videoCategories?part=snippet®ionCode=NL&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
Response
{
"kind": "youtube#videoCategory",
"etag": "7mqChSJogdF3hSIL-88BfDE-W8M",
"id": "17",
"snippet": {
"title": "Sports",
"assignable": true,
"channelId": "UCBR8-60-B28hp2BmDPdntcQ"
}
}
I'm trying to create a webhook here:
curl --header "X-Shopify-Access-Token: <token>" -d '{"webhook": {"topic": "orders/create", "address": "http://www.google.com/", "format": "json"}}' https://test-store-402.myshopify.com/admin/webhooks.json
Here's the JSON pretty-printed for readability:
{
"webhook": {
"topic": "orders/create",
"address": "http://www.google.com/",
"format": "json"
}
}
It's returning this error:
{"errors":{"topic":["can't be blank","Invalid topic specified. Topics allowed: orders/create, orders/updated, orders/paid, orders/cancelled, orders/fulfilled, orders/partially_fulfilled, app/uninstalled, customer_groups/create, customer_groups/update, customer_groups/delete, products/create, products/update, products/delete, collections/create, collections/update, collections/delete, carts/create, carts/update"],"address":["can't be blank"]}}
I've confirmed:
The spelling of the topic is correct
The JSON request payload is wrapped in "webhook" (singular) correctly, as per the docs
I've copied and pasted the JSON into jsonlint.com to sanity check that the JSON is valid
Confused...didn't see any other questions on SO related to this specifically, I must be doing something terribly obvious wrong - or else everyone would be hitting this issue.
UPDATE: I got it to work over command-line by passing in the Content-type: application/json header. But now I'm having problems over curl_exec in PHP. I have the following CURLOPT's set:
CURLOPT_RETURNTRANSFER: true
CURLOPT_SSL_VERIFYPEER: false
CURLOPT_FOLLOWLOCATION: true
CURLOPT_MAXREDIRS: 10
CURLOPT_CUSTOMREQUEST: 'POST'
CURLOPT_HTTPHEADER: array {
0 => string 'X-Shopify-Access-Token: <token>'
1 => string 'Content-type: application-json' (length=30)
Note that I can do GET's just fine over curl - only POSTs returning this confusing response.
Got it to work in curl_exec. Here's what I'm using:
CURLOPT_RETURNTRANSFER: true
CURLOPT_SSL_VERIFYPEER: false
CURLOPT_FOLLOWLOCATION: true
CURLOPT_MAXREDIRS: 10
CURLOPT_CUSTOMREQUEST: 'POST'
CURLOPT_HTTPHEADER: array {
0 => string 'X-Shopify-Access-Token: <token>'
1 => string 'Content-type: application-json' (length=30)
CURLOPT_POSTDATA: '{"webhook":{"topic":"orders/updated","address":"http://www.google.com","format":"json"}}'
I think the problem may have been that I left out the CURLOPT_POSTDATA in my Update above.