I am looking to send pull request to multiple reviewers in bitbucket. Currently I have json and curl request as below
{
"title": "PR-Test",
"source": {
"branch": {
"name": "master"
}
},
"destination": {
"branch": {
"name": "prd"
}
},
"reviewers": [
{
"uuid": "{d543251-6455-4113-b4e4-2fbb1tb260}"
}
],
"close_source_branch": true
}
curl -u "user:pass" -H "Content-Type: application/json" https://api.bitbucket.org/2.0/repositories/companyname/my-repo/pullrequests -X POST --data #my-pr.json
The above curl command works. I need the json syntax to pass either multiple usernames or multiple UUID in the reviewers list.
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pullrequests
The documentation you linked to seems to indicate that something like this should work:
"reviewers": [
{
"uuid": "{504c3b62-8120-4f0c-a7bc-87800b9d6f70}"
},
{
"uuid": "{bafabef7-b740-4ee0-9767-658b3253ecc0}"
}
]
Related
I am trying to write cloud code that excludes certain values from a query. I have tried using both select() and exclude() to limit what values come back in a query. Here is what my code looks like
Parse.Cloud.beforeFind(Parse.User, (request) => {
return request.query.select('email');
});
For reference, here is the curl command that I am using to test my cloud code:
curl --location --request GET 'https://<parse-server>.b4a.io/parse/users' \
--header 'X-Parse-Application-Id: <app-id>' \
--header 'X-Parse-REST-API-Key: <api-key>' \
--header 'X-Parse-Session-Token: <token>'
In theory, the response to this command should look something like this:
{
results:[{'email':'123#example.com'},{'email':'456#example.com'}']
}
Instead what I get is the following(all of the user information I would normally get if I did nothing):
{
"results": [
{
"objectId": "jKXYLgeB6x",
"username": "cperryoh",
"email": "123#example.com",
"isBanned": false,
"emailVerified": true,
"createdAt": "2022-07-25T17:09:37.963Z",
"updatedAt": "2022-07-27T16:34:54.186Z",
"chunksOwned": {
"__type": "Relation",
"className": "chunk"
},
"ACL": {
"jKXYLgeB6x": {
"read": true,
"write": true
},
"*": {
"read": true
}
}
},
{
"objectId": "ykJJhvNuPh",
"username": "testUser",
"email":"456#example.com"
"isBanned": false,
"emailVerified": true,
"createdAt": "2022-07-25T19:39:02.854Z",
"updatedAt": "2022-07-27T16:20:48.083Z",
"chunksOwned": {
"__type": "Relation",
"className": "chunk"
},
"ACL": {
"*": {
"read": true
},
"ykJJhvNuPh": {
"read": true,
"write": true
}
}
}
]
}
To further add to the confusion, in the cloud-code/parse-SDK documentation, there is no reference to the beforeFind trigger. So I am not even sure what the return type of lambda/function is supposed to be. The only thing I have that is telling me I can return a query object is an example in the cloud code guide here. In one of the examples, they return the result of Parse.Query.or() which does return an object of type Query. Am I using .select() incorrectly or is it not meant for what I am trying to do? Thanks for the help!
Try just:
Parse.Cloud.beforeFind(Parse.User, (request) => {
request.query.select('email');
});
I am just starting with Elasticsearch and I have started with adding an index, which works and I can get information about it:
GET http://localhost:9200/megacorp
"megacorp": {
"aliases": {},
"mappings": {},
"settings": {
"index": {
"routing": {
"allocation": {
"include": {"_tier_preference": "data_content"
}
}
},
"number_of_shards": "1",
"provided_name": "megacorp",
"creation_date": "1657286196414",
"number_of_replicas": "1",
"uuid": "HbsAAv-mRziSUKGiXPMyPA",
"version": {
"created": "8030299"
The problem comes when I try to add a document, I get the following error:
PUT http://localhost:9200/megacorp/empoyee/1
"first_name": "John",
"last_name": "Smith",
"age": 25,
"about": "I love to go rock climbing",
"interests": ["sports", "music"]
"error": "no handler found for uri [/megacorp/empoyee/1] and method [PUT]"
I think I've done everything right, but it still does not work.
Problem here, that you are using wrong URL in your request.
According to documentation you must use use following paths for document index:
Request
PUT /<target>/_doc/<_id>
POST /<target>/_doc/
PUT /<target>/_create/<_id>
POST /<target>/_create/<_id>
So you are missing _doc or _create part.
UPDATE:
cURL Example
curl -X PUT --location "http://localhost:9200/megacorp/1" \
-H "Content-Type: application/json" \
-d "{
\"first_name\": \"John\",
\"last_name\": \"Smith\",
\"age\": 25,
\"about\": \"I love to go rock climbing\",
\"interests\": [\"sports\", \"music\"]
}"
From elasticsearch 8.x mapping types are removed. You need to use this for indexing the documents
http://localhost:9200/megacorp/_doc/1
I've been working on creating a script utilizes curl and variables. Doing some searches I found how to place a variable in the data portion of the curl but now I'm getting errors from the curl command.
(Some parts of the code removed to keep passwords out, everything is working except for entering the data into the --data portion of curl)
curlData=$(cat <<EOF
{
"rebootClient": false,
"createPseudoClientRequest": {
"registerClient": true,
"clientInfo": {
"clientType": 0,
}
},
"packages": [
{
"packageId": 702,
"packageName": "File System",
"packageId": 51,
"packageName": "MediaAgent"
}
],
},
"entities": [
{
"clientId": 0,
}
]
}
EOF
)
shopt -u nocasematch #Sets options back to being case sensitive
echo "$csName"
curl -vv --location --request POST "http://$csName:81/SearchSvc/CVWebService.svc/InstallClient" --header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header "Authtoken: $token" \
-d "$curlData"
Doing a bash -x everything looks correct
"rebootClient": false,
"createPseudoClientRequest": {
"registerClient": true,
"clientInfo": {
"clientType": 0,
}
},
"packages": [
{
"packageId": 702,
"packageName": "File System",
"packageId": 51,
"packageName": "MediaAgent"
}
],
"clientAuthForJob": {
},
"entities": [
{
"clientId": 0,
"clientName": "srybrcost",
}
]
}'
But every time I get Request body is empty or format is invalid
I'm trying to insert a JSON data file in my elasticsearch instance.
curl -s -H “Content-Type: application/x-ndjson” -XPOST localhost:9200/_bulk —-data-binary “#restaurants.json”; echo
However, after executing this command I get an error that says
{"error":{"root_cause":[{"type":"parse_exception","reason":"request body is required"}],"type":"parse_exception","reason":"request body is required"},"status":400}
The JSON file basically has an array of the below object.
Only thing is that I've put just one object here to save space. However, there are more than one objects present.
Structure is like given below;
[
{
"address": {
"building": "351",
"coord": [
-73.98513559999999,
40.7676919
],
"street": "West 57 Street",
"zipcode": "10019"
},
"borough": "Manhattan",
"cuisine": "Irish",
"name": "Dj Reynolds Pub And Restaurant",
"grades": [
{
"date": {
"$date": "2014-09-06T00:00:00.000Z"
},
"grade": "A",
"score": 2
},
{
"date": {
"$date": "2013-07-22T00:00:00.000Z"
},
"grade": "A",
"score": 11
},
{
"date": {
"$date": "2012-07-31T00:00:00.000Z"
},
"grade": "A",
"score": 12
},
{
"date": {
"$date": "2011-12-29T00:00:00.000Z"
},
"grade": "A",
"score": 12
}
],
"id": "30191841"
}
]
The bulk API requires one document per line, which means you can't have newlines in your documents. Try stripping all the white spaces from the JSON you're submitting. You are also just submit a stream of documents, and not a JSON array of objects. See Bulk API documentation here: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
I had this same issue in Windows and am posting this here for anyone that comes across the same question with this error referenced.
{"error":{"root_cause":[{"type":"parse_exception","reason":"request body is required"}],"type":"parse_exception","reason":"request body is required"},"status":400}
I found at least two causes:
cURL doesn't know where the file you are trying to load is:
In this case, make sure to run cURL from the directory where the file is located. Try executing the following command and making sure you see the file.
more file.json
Windows command line DOES NOT support single quotes within the cURL command line:
BAD
curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/_bulk' --data-binary '#file.json'
GOOD
curl -H "Content-Type: application/x-ndjson" -XPOST "localhost:9200/_bulk" --data-binary "#file.json"
I solved it by wrapping the url with quotation mark.
curl -s -H “Content-Type: application/x-ndjson” -XPOST "localhost:9200/_bulk —-data-binary “#restaurants.json”;
I want to change via the XCode Bots API the scheme name of a bot. A request like curl -XPATCH -H 'Content-Type: application/json' -H 'x-xcsclientversion: 8' https://localhost:20343/api/bots/botid123 -d '{"name": "myawesomebot2"}' to change the bot name works. But if I try to change the configuration object with a request body like '{"configuration": {"schemeName": "scheme2"}}' it fails.
How can the scheme name be modified?
I finally got this solved and want to note the pieces necessary to make this work and how I found it.
First, as you already noticed, is the need for -H "x-xcsclientversion: #" (note, 6 worked for me, as discovered through a check of Apple's Javascript that receives the PATCH request)
Second, after watching Xcode Server update a bot through Charles, it was seen that the URL needs the following parameter added, ?overwriteBlueprint=true
Third, it seems that the JSON data, at the topmost level as name:, also requires requiresUpgrade=false and type=1 (I found the tool jq to be invaluable)
Fourth, changes to the sourceBlueprint requires configuration.sourceControlBlueprint.DVTSourceControlWorkspaceBlueprintIdentifierKey to receive a new UUID. Easily generated in bash by uuidgen command.
Fifth, a mostly-full bot description must be sent. I grabbed the bot's JSON definition through Apple's API, then modified it using jq (see above), deleting out unnecessary key/value pairs so as to match Xcode Server's own API calls. The necessary key/value pairs appear to be:
name
type
requiresUpgrade
configuration (modify as necessary, but a full configuration must be sent)
group (leave as-is, but send it back through)
Sixth, backslash-escape all forward-slashes in the JSON payload. I've done this in bash with ESCAPED_JSON=${BOT_CONFIG_JSON//\//\\\/} and I send -d "$ESCAPED_JSON" in the curl command.
As such, the full curl command I'm using becomes:
curl -k --request PATCH -H "Content-Type: application/json" -H "x-xcsclientversion: 6" -d "$ESCAPED_JSON" https://<username>:<password>#<your_server_address>:20343/api/bots/<your_bot_id>?overwriteBlueprint=true
And a full JSON definition (remember, it must have forward slashes escaped before sending) looks like this
<!-- language: lang-json -->
"requiresUpgrade": false,
"configuration": {
"triggers": [
{
"phase": 1,
"scriptBody": "<REDACTED>",
"type": 1,
"name": "Update github Pending",
"conditions": {
"status": 2,
"onSuccess": true,
"onAnalyzerWarnings": true,
"onBuildErrors": true,
"onWarnings": true,
"onFailingTests": true
}
},
{
"phase": 2,
"scriptBody": "<REDACTED>",
"type": 1,
"name": "Upload to Beta",
"conditions": {
"status": 2,
"onSuccess": true,
"onAnalyzerWarnings": true,
"onBuildErrors": false,
"onWarnings": true,
"onFailingTests": false
}
},
{
"phase": 2,
"scriptBody": "<REDACTED>",
"type": 1,
"name": "Update github status",
"conditions": {
"status": 2,
"onSuccess": true,
"onAnalyzerWarnings": true,
"onBuildErrors": false,
"onWarnings": true,
"onFailingTests": false
}
}
],
"performsUpgradeIntegration": true,
"disableAppThinning": true,
"deviceSpecification": {
"filters": [
{
"platform": {
"_id": "3c884e2499df662057e8c64580003419",
"displayName": "iOS",
"_rev": "8-51c114fcfc83ea5f36df66f119b34ec8",
"simulatorIdentifier": "com.apple.platform.iphonesimulator",
"identifier": "com.apple.platform.iphoneos",
"buildNumber": "14C89",
"version": "10.2"
},
"filterType": 3,
"architectureType": 0
}
],
"deviceIdentifiers": [
"6d928bd891b83b4b8592aedb42001a97",
"6d928bd891b83b4b8592aedb4200776c",
"fa737f03db7b6c04d4c7f9507100700f"
]
},
"periodicScheduleInterval": 0,
"schemeName": "<REDACTED>",
"codeCoveragePreference": 2,
"performsTestAction": true,
"scheduleType": 3,
"performsArchiveAction": true,
"builtFromClean": 2,
"buildConfiguration": "Release",
"performsAnalyzeAction": true,
"sourceControlBlueprint": {
"DVTSourceControlWorkspaceBlueprintLocationsKey": {
"A2739AD29C3BCDF8619D0305ACFDD0C22AEBDDB1": {
"DVTSourceControlWorkspaceBlueprintLocationTypeKey": "DVTSourceControlLockedRevisionLocation",
"DVTSourceControlLocationRevisionKey": "9d38dc7507f0f6ac17072d721893f0021c5282ed"
},
"51DBFAD1848AC646B864BBBEDC625B8BAB305A76": {
"DVTSourceControlBranchIdentifierKey": "<THE BRANCH TO WATCH>",
"DVTSourceControlBranchOptionsKey": 4,
"DVTSourceControlWorkspaceBlueprintLocationTypeKey": "DVTSourceControlBranch"
}
},
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey": "51DBFAD1848AC646B864BBBEDC625B8BAB305A76",
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey": {},
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationStrategiesKey": {
"A2739AD29C3BCDF8619D0305ACFDD0C22AEBDDB1": {
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationTypeKey": "DVTSourceControlAuthenticationStrategy"
},
"51DBFAD1848AC646B864BBBEDC625B8BAB305A76": {
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationTypeKey": "DVTSourceControlAuthenticationStrategy"
}
},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey": {
"A2739AD29C3BCDF8619D0305ACFDD0C22AEBDDB1": 0,
"51DBFAD1848AC646B864BBBEDC625B8BAB305A76": 0
},
"DVTSourceControlWorkspaceBlueprintIdentifierKey": "<GENERATE A NEW UUID FOR THIS!!!>",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey": {
"A2739AD29C3BCDF8619D0305ACFDD0C22AEBDDB1": "<REDACTED PATH 1>",
"51DBFAD1848AC646B864BBBEDC625B8BAB305A76": "<REDACTED PATH 2>"
},
"DVTSourceControlWorkspaceBlueprintNameKey": "Cool Blueprint",
"DVTSourceControlWorkspaceBlueprintVersion": 204,
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey": "<REDACTED>.xcworkspace",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey": [
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey": "git#github.com:<REDACTED REPO 1>",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey": "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey": "A2739AD29C3BCDF8619D0305ACFDD0C22AEBDDB1"
},
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey": "git#github.com:<REDACTED REPO 2>",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey": "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey": "51DBFAD1848AC646B864BBBEDC625B8BAB305A76"
}
]
},
"exportsProductFromArchive": true,
"weeklyScheduleDay": 0,
"minutesAfterHourToIntegrate": 0,
"testingDestinationType": 0,
"hourOfIntegration": 0,
"testingDeviceIDs": []
},
"group": {
"name": "41A62776-A72E-44C0-BFF0-D91F699BBA6A"
},
"type": 1,
"name": "My Cool Integration Bot"
I hope this helps.