Bitbucket API adding branch restriction - malformed groups - bitbucket-api

Trying to add branch restriction to a repository, I was successful in adding a rule, however, I cannot get a group added to the rule.
curl -XPOST --user user:password -H "Content-Type: application/json" -d '{"kind": "push", "pattern": "testing*", "groups": {"name": "testleads"}}' $URL/api/2.0/repositories/team/repo/branch-restrictions
Result:
{"error": {"message": "malformed groups"}}
I have tried different combinations in the groups using full_slug, slug and also changing the inheritance types.
-d '{"kind": "push", "pattern": "testing*", "groups":["name": "devleads"]}'
-d '{"kind": "push", "pattern": "testing*", "groups": {"name": "devleads"}}'
Has anyone tried this?

After a lot of tries, I narrowed it down to this JSON input to be able to add branch restrictions
-d '{"kind": "push", "pattern": "test*", "value": null, "groups": [{"name": "devLeads", "account_privilege": null, "full_slug": "team-name:devleads", "owner": {"username": "team-name", "display_name": "Team Name ", "type": "team"}, "type": "group", "slug": "devleads"}]}'

I'm late to the game but figured my answer might be useful for anyone who is struggling with this like I was just now. I found the minimum syntax for a group specification is as follows:
'groups': [{'name': 'development_team'}]
So, in my context (using python) the following could be posted to the BitBucket API successfully:
request_json = {
"kind": "push",
"branch_match_kind": "glob",
"pattern": "*_bugfix",
'groups': [{'name': 'development_team'}]
}
lock_response = requests.post(api_url, json=request_json, auth=bb_creds)

Related

LinkedIn UGC Posts API with projection returns invalid paging URL

I would like to retrieve UGC posts from organization's profile using the ugcPosts API. I would also like to receive links to video streams with the response, so I use the following projection (based on this answer):
(paging,elements*(id,created,specificContent(com.linkedin.ugc.ShareContent(shareMediaCategory,shareCommentary,media(*(media~:playableStreams,originalUrl,description,title,thumbnails))))))
My whole request looks like this (retrieving the posts of the official test organization):
curl --request GET \
--url 'https://api.linkedin.com/v2/ugcPosts?q=authors&sortBy=LAST_MODIFIED&projection=(paging%2Celements*(id%2Ccreated%2ClastModified%2Cauthor%2CspecificContent(com.linkedin.ugc.ShareContent(shareMediaCategory%2CshareCommentary%2Cmedia(*(media~%3AplayableStreams%2CoriginalUrl%2Cdescription%2Ctitle%2Cthumbnails))))))&authors=List(urn%3Ali%3Aorganization%3A2414183)' \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--header 'X-Restli-Protocol-Version: 2.0.0'
The request works as fine. But I run into an issue if I want to follow to the next page using the provided URL in paging; this is the relevant response:
{
"paging": {
"total": 284243,
"count": 10,
"start": 0,
"links": [
{
"rel": "next",
"type": "application/json",
"href": "/v2/ugcPosts?q=authors&start=10&count=10&sortBy=LAST_MODIFIED&projection=%28paging%2Celements*%28id%2Ccreated%2ClastModified%2Cauthor%2CspecificContent%28com.linkedin.ugc.ShareContent%28shareMediaCategory%2CshareCommentary%2Cmedia%28*%28media~%3AplayableStreams%2CoriginalUrl%2Cdescription%2Ctitle%2Cthumbnails%29%29%29%29%29%29&authors=List(urn%3Ali%3Aorganization%3A2414183)"
}
]
}
}
On the first page, you can see that parentheses in the projection parameter got URL encoded, while authors parameter remains the same. This request still works, but if I follow the URL one more time, I recieve the following paging data:
{
"paging": {
"total": 284243,
"count": 10,
"start": 10,
"links": [
{
"rel": "prev",
"type": "application/json",
"href": "/v2/ugcPosts?q=authors&start=0&count=10&sortBy=LAST_MODIFIED&projection=%2528paging%252Celements*%2528id%252Ccreated%252ClastModified%252Cauthor%252CspecificContent%2528com.linkedin.ugc.ShareContent%2528shareMediaCategory%252CshareCommentary%252Cmedia%2528*%2528media~%253AplayableStreams%252CoriginalUrl%252Cdescription%252Ctitle%252Cthumbnails%2529%2529%2529%2529%2529%2529&authors=List(urn%3Ali%3Aorganization%3A2414183)"
},
{
"rel": "next",
"type": "application/json",
"href": "/v2/ugcPosts?q=authors&start=20&count=10&sortBy=LAST_MODIFIED&projection=%2528paging%252Celements*%2528id%252Ccreated%252ClastModified%252Cauthor%252CspecificContent%2528com.linkedin.ugc.ShareContent%2528shareMediaCategory%252CshareCommentary%252Cmedia%2528*%2528media~%253AplayableStreams%252CoriginalUrl%252Cdescription%252Ctitle%252Cthumbnails%2529%2529%2529%2529%2529%2529&authors=List(urn%3Ali%3Aorganization%3A2414183)"
}
]
}
}
You can see here that the projection parameter got URL-encoded again (having %252C for parens) and following that URL returns error 400.
I think this is a bug in the API, but since LinkedIn recommends to use Stack Overflow for support, I just wrote this up here, hopeful someone notices. Perhaps could you suggest another way of contacting LinkedIn about this bug in their API?
Meanwhile I resorted to constructing the pagination URL manually.

Error 2003 when analyzing results for Custom Model

Using this link: https://learn.microsoft.com/en-us/azure/cognitive-services/form-recognizer/quickstarts/curl-train-extract I follow each step and use the sample data in the guide. All of them are successful until the last step which is "Get the Analyze results", where it returns the following:
{
"status": "failed",
"createdDateTime": "2020-07-09T14:59:12Z",
"lastUpdatedDateTime": "2020-07-09T14:59:14Z",
"analyzeResult": {
"version": null,
"readResults": null,
"pageResults": null,
"documentResults": null,
"errors": [
{
"code": "2003",
"message": "Download failed. Please check your input URL."
}
]
}
}
Unfortunately, there are no references to error codes and possible explanation/solutions. Assistance is highly appreciated.
The error message is quite clear: the url that you provided for the analysis does not allow the service to download the document.
Please check the content that you sent during the operation called "Analyze forms for key-value pairs and tables":
curl -v "https://<Endpoint>/formrecognizer/v2.0/custom/models/<model ID>/analyze" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: <subscription key>" -d "{ \"source\": \""<SAS URL>"\" } "
In particular, can you detail the last part? The piece with the '' block is the one causing the error

issues while posting data from curl to Firestore throw curl

I am very beginner to Google Firestore (also to Firebase). I am doing a simple POC and I am suffering a bit to interact with FireStore. Well, reading the data from Angular worked as a charm so easy. Nevertheless, simple actions like add a new data from curl or deleting the collection from FireBase Cli has taken me the whole day without progress . Just to stress how dummy I am in FireStore, I have used ElasticSearch local installed so I am trying similar behaviours/tools/functionalities like posting/creating fields from curl/postman (it is not part of this question compare one another, just exposing my limitations) but I just can't move forward.
This is how I connected successfully from Angular:
firebaseConfig : {
apiKey: "*** removed ***",
authDomain: "transfer-status-realtime.firebaseapp.com",
databaseURL: "https://transfer-status-realtime.firebaseio.com",
projectId: "transfer-status-realtime",
storageBucket: "transfer-status-realtime.appspot.com",
messagingSenderId: "143612370857",
appId: "1:143612370857:web:a9d0b21e3a58520ed02eb8",
measurementId: "G-WT5C346D7T"
}
I have based mainly my tentatives in Making Rest Calls and other stack overflow question
My last and recent tried:
c:\temp>curl -X POST -H "Content-Type: application/json" -d'{"fields": {"status": "success"}}' "https://firestore.googleapis.com/v1beta1/projects/transfer-status-realtime/databases/(default)/documents/transfers?&key=***removed***"
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] unmatched close brace/bracket in column 8
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Closing quote expected in string.\n\n^",
"status": "INVALID_ARGUMENT"
}
}
So my main issue: how add data to FireStore from curl?
In case it matter, here is my database console:
Other tentatives probably in wrong direction I have tried are:
According to https://firebase.google.com/docs/database/rest/save-data, I can save fields by using PUT so I tried write a curl command and I got stuck because I don't know what would be the "fireblog" in my case?
curl -X PUT -d '{
"transfers": {
"id": "idfromPut",
"status": 1
}
}' 'https://transfer-status-realtime.firebaseio.com/rest/saving-data/fireblog/users.json'
I also tried but what would be message_list in my case?
curl -X POST -d '{"status" : 2}' 'https://transfer-status-realtime.firebaseio.com/message_list.json'
*** edited
c:\temp>curl -X POST -H "Content-Type: application/json" -d "{\"fields\": {\"status\": \"success\"}}" "https://firestore.googleapis.com/v1/projects/transfer-status-realtime/databases/(default)/documents/transfers?&key=*** removed ***"
{
"error": {
"code": 400,
"message": "Invalid value at 'document.fields[0].value' (type.googleapis.com/google.firestore.v1.Value), \"success\"",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "document.fields[0].value",
"description": "Invalid value at 'document.fields[0].value' (type.googleapis.com/google.firestore.v1.Value), \"success\""
}
]
}
]
}
}
In case it is relevant, same issue using external json file
C:\WSs\reactive-stack\reactive-front\src>curl -X POST -H "Content-Type: application/json" -d #load-data-tofirestore.json "https://firestore.googleapis.com/v1/projects/transfer-status-realtime/databases/(default)/documents/transfers?&key=***removed"
{
"error": {
"code": 400,
"message": "Invalid value at 'document.fields[0].value' (type.googleapis.com/google.firestore.v1.Value), \"success\"",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "document.fields[0].value",
"description": "Invalid value at 'document.fields[0].value' (type.googleapis.com/google.firestore.v1.Value), \"success\""
}
]
}
]
}
}
And here is the json file
{"fields": {"status": "success"}}
* SOLUTION *
from cUrl
C:\WSs\reactive-stack\reactive-front\src>curl -H "Content-Type: application/json" -X POST https://firestore.googleapis.com/v1/projects/transfer-status-realtime/databases/(default)/documents/transfers -d "{\"fields\": { \"status\": { \"stringValue\": \"outro status\" } }}"
{
"name": "projects/transfer-status-realtime/databases/(default)/documents/transfers/ddwHxjy7eQV3640pW0Xx",
"fields": {
"status": {
"stringValue": "outro status"
}
},
"createTime": "2020-04-06T16:21:16.453553Z",
"updateTime": "2020-04-06T16:21:16.453553Z"
}
from PowerShell
PS C:\Users> $body = #"
>> {
>> "fields": {
>> "status": {
>> "stringValue": "fracasso"
>> }
>> }
>> }
>> "#
>>
PS C:\Users\Cast> $params = #{
>> Uri = 'https://firestore.googleapis.com/v1/projects/transfer-status-realtime/databases/(default)/documents/transfers'
>> Method = 'POST'
>> Body = $body
>> ContentType = 'application/json'
>> }
>>
PS C:\Users\Cast> Invoke-RestMethod #params
name fields createTime
---- ------ ----------
projects/transfer-status-realtime/databases/(default)/documents/transfers/z4TB6gzcgXMRUGR8ecek #{status=} 2020-04-06...
PS C:\Users>
I believe the root cause of your issue is due to cURL on a windows system. As seen in this other question, there are limitations on how the command line arguments are parsed in a windows shell.
Instead of using this:
-d'{"fields": {"status": "success"}}'
You should state your payload as:
-d "{\"fields\": {\"status\": \"success\"}}"
Another solution could be writing the JSON in a file and using its path in the cURL query. I believe you could keep the right JSON format this way, but you would be forced to use a file, which is far from optimal if you don't intend to send the same payload multiple times:
-d #file_with_data.json

Ad Targeting - Find Entities by URNs API ClassCastException error message

I have some problem with the "Find Entities by URNs" API in order to retrieve the metadata and value information for a collection of URNs.
If I use the URL described in the doc (Sample request) with a valid access token:
https://api.linkedin.com/v2/adTargetingEntities?q=urns&urns=List(urn%3Ali%3AfieldOfStudy%3A100990,urn%3Ali%3Aorganization%3A1035,urn%3Ali%3Aseniority%3A9)&locale=(language:en,country:US)&oauth2_access_token=<a-valid-token>
I receive the message:
{
"serviceErrorCode": 0,
"message": "java.lang.ClassCastException",
"status": 500
}
Anyone have experience the same issue? Any idea how to fix it?
Also: how can i contact for technical support as in this case?
UPDATE:
I made some try and I fix using the following version:
https://api.linkedin.com/v2/adTargetingEntities?q=urns&urns=urn%3Ali%3AfieldOfStudy%3A100990&urns=urn%3Ali%3Aorganization%3A1035&urns=urn%3Ali%3Aseniority%3A9&locale.language=it&locale.country=IT&oauth2_access_token=<a-valid-token>
BUT the locale/language translation is not working. Could be this a working solutions?
From the support team:
Our docs are missing 1 critical piece of information. Whenever using
LIST and encoded URNs in the URL, we expect an additional header 'x-restli-protocol-version: 2.0.0'
The correct API call would be Request:
curl -X GET \
'https://api.linkedin.com/v2/adTargetingEntities?q=urns&urns=List(urn%3Ali%3Aindustry%3A1,urn%3Ali%3Aseniority%3A9)&locale=(language:it,country:IT)'
\
-H 'x-restli-protocol-version: 2.0.0' \
-H 'Authorization: Bearer <Token>'
Response:
{
"elements": [
{
"facetUrn": "urn:li:adTargetingFacet:industries",
"name": "Difesa e spazio",
"urn": "urn:li:industry:1"
},
{
"facetUrn": "urn:li:adTargetingFacet:seniorities",
"name": "Partner",
"urn": "urn:li:seniority:9"
}
],
"paging": {
"count": 2147483647,
"links": [],
"start": 0
}
}
Yes, it does provide a response in locale.
Hope this can help other guys in the future

Alfresco REST API: How do I list folders in the site?

Given this URL
http://localhost:8080/alfresco/service/api/sites/test-3
I get back:
{
"url": "\/alfresco\/service\/api\/sites\/test-3",
"sitePreset": "site-dashboard",
"shortName": "test-3",
"title": "Test 3",
"description": "",
"node": "\/alfresco\/service\/api\/node\/workspace\/SpacesStore\/0352afea-797f-4b9e-be27-3bf37e54a2f1",
"tagScope": "\/alfresco\/service\/api\/tagscopes\/workspace\/SpacesStore\/0352afea-797f-4b9e-be27-3bf37e54a2f1",
"siteManagers":
[
"admin"
],
"isPublic": true,
"visibility": "PUBLIC"
}
How to I use that info to get the list of folders in the site?
You need to use a different API. Look at this shell session:
$ curl -u admin:admin -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d "{'shortName':{'values':['test'], 'match':'foo'}}" http://localhost:8080/alfresco/service/api/sites/query
{
"url" : "\/alfresco\/service\/api\/sites\/test",
"sitePreset" : "wcmqs-site-dashboard",
"shortName" : "test",
"title" : "test",
"description" : "",
"node" : "\/alfresco\/service\/api\/node\/workspace\/SpacesStore\/e597e4c2-d307-46e3-ba4d-b911262e7261",
"tagScope" : "\/alfresco\/service\/api\/tagscopes\/workspace\/SpacesStore\/e597e4c2-d307-46e3-ba4d-b911262e7261",
"isPublic" : false,
"visibility" : "PRIVATE",
"siteManagers" :
[
"admin"
]
}
// see the 'node' property up there
$ curl -u admin:admin http://p01:8080/alfresco/service/api/node/workspace/SpacesStore/e597e4c2-d307-46e3-ba4d-b911262e7261/children
[..cmis response here..]
One option is to use CMIS. Depending on your exact needs though, you can use some built in webscripts to do the listings too
Within the root of a site, you have Containers, such as documentLibrary and wiki. You can get a list of the containers for a site from the container.get webscript. Take a look at org/alfresco/slingshot/documentlibrary/container.get.desc.xml for the details. The URL pattern for it, as shown in that file, is /slingshot/doclib/containers/{site}
curl -u admin:admin http://localhost:8080/alfresco/service/slingshot/doclib/containers/test
{
"containers":
[
{
"name": "documentLibrary",
"description": "Document Library",
"nodeRef": "workspace://SpacesStore/973338a0-db39-458e-a10d-396f00cb16a3",
"type": "cm:folder"
}
]
}
Next, when you know what container or folder within a container you want to use, the treenode.get webscript can let you list that, eg
curl -u admin:admin http://localhost:8080/alfresco/service/slingshot/doclib/treenode/site/test/documentLibary
{
"totalResults": 0,
"resultsTrimmed": false,
"parent":
{
"nodeRef": "workspace://SpacesStore/92e4f8de-b919-4540-a27a-16c4e53a57bc",
"userAccess":
{
"create": true,
"edit": true,
"delete": true
}
},
"items":
[
]
}
I can also recommend you use http://localhost:8080/alfresco/service/index to view what webscripts are present in your system, and get information on them, it helps a lot for situations like this
Load a site: http://localhost:8080/alfresco/service/api/sites/test-3
{
"url": "\/alfresco\/service\/api\/sites\/test-3",
"sitePreset": "site-dashboard",
"shortName": "test-3",
"title": "test 3",
"description": "",
"node": "\/alfresco\/service\/api\/node\/workspace\/SpacesStore\/0352afea-797f-4b9e-be27-3bf37e54a2f1",
"tagScope": "\/alfresco\/service\/api\/tagscopes\/workspace\/SpacesStore\/0352afea-797f-4b9e-be27-3bf37e54a2f1",
"siteManagers":
[
"admin"
],
"isPublic": true,
"visibility": "PUBLIC"
}
Get the site contents using the ID extracted from the node property: http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/0352afea-797f-4b9e-be27-3bf37e54a2f1/children
Inside that is a node with the title "documentLibrary". Using its ID GUID, you can fetch some more children
http://localhost:8080/alfresco/service/cmis/s/workspace:SpacesStore/i/b68db1eb-547d-4b2c-b5eb-ba207a275789/children
If you have custom properties, they will appear on the child items using this API call.
Using the ID of the child item, you can get its content.
http://localhost:8080/alfresco/service/cmis/s/workspace:SpacesStore/i/2d53f464-bea0-46f3-aa0c-10b3302e661c/content
Use this url to get folder list.
http://localhost:8080/alfresco/service/api/node/workspace:SpacesStore/store_id/b0697dd1-ae94-4bf6-81c8-5e2fa098ddfa/children

Resources