Wondering how I would make this into an Alamofire Parameter.
curl -X GET \
-H "X-Parse-Application-Id: myAppId" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-G \
--data-urlencode 'where={"post":{"$inQuery":{"where":{"image":{"$exists":true}},"className":"Post"}}}' \
https://YOUR.PARSE-SERVER.HERE/1/classes/Comment
The part that's confusing is the --data-urlencode
Here's what I got so far:
let params: Parameters = [
"where": ["post": ["$inQuery" : "where": ]],
]
I'm stuck, do I keep nesting Parameters?
Related
Is it possible to set an assignee and apply a transition (change status) in a single call to the Jira Cloud REST API? The example from the documentation here seems to imply that you can, but it does not work when I tested it.
Here's some examples (with curl):
setting an assignee works
curl --request PUT \
--url "https://mysite.atlassian.net/rest/api/2/issue/project-123" \
--user "johnsmith#example.com:abcdef1234567890abcdef00" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '{
"fields": {
"assignee": { "accountId": "987654321fedcba987654321" }
}
}'
applying a transition works too
curl --request POST \
--url "https://mysite.atlassian.net/rest/api/2/issue/project-123/transitions" \
--user "johnsmith#example.com:abcdef1234567890abcdef00" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '{
"transition": { "id": 1 }
}'
error saying that assignee cannot be set
curl --request POST \
--url "https://mysite.atlassian.net/rest/api/2/issue/project-123/transitions" \
--user "johnsmith#example.com:abcdef1234567890abcdef00" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '{
"fields": {
"assignee": {
"accountId": "987654321fedcba987654321"
}
},
"transition": {
"id": 1
}
}'
sets assignee, but doesn't apply transition
curl --request PUT \
--url "https://mysite.atlassian.net/rest/api/2/issue/project-123" \
--user "johnsmith#example.com:abcdef1234567890abcdef00" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '{
"fields": {
"assignee": {
"accountId": "987654321fedcba987654321"
}
},
"transition": {
"id": 1
}
}'
you cannot do that in one request because you're sending them to two different URLs.
On JIRA Server 8.7.1, was able to successfully transition using the name property (instead of accountId).
curl --request POST \
--url "https://mysite.atlassian.net/rest/api/2/issue/project-123/transitions" \
--user "johnsmith#example.com:abcdef1234567890abcdef00" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '{
"fields": {
"assignee": {
"name": "will"
}
},
"transition": {
"id": 1
}
}'
Otherwise I got the following error:
{
"errorMessages": [],
"errors": {
"assignee": "expected Object containing a 'name' property"
}
}
I am trying to run the below CURL command to trigger a JENKINS job with huge list of parameters. Job gets submitted , but it does not read my parameters that i sent , instead picks up the defaults.
curl -v -X POST \
'https://jenkins_URL/buildWithParameters?' \
-H 'Content-Type: application/json' \
--user ABC:token \
--form json='{\"parameter\":[{\"name\":\"ACTION\", \"value\":\"ONBOARD_NEWUSECASE"\ } \
,{\"name\":\"Name\", \"value\":\"ABC\"} \
,{\"name\":\"Number\", \"value\":\"123456789\"} \
,{\"name\":\"sample\", \"value\":\"SAMPLE\"} \
,{\"name\":\"A1\", \"value\":\"V1\"} \
,{\"name\":\"A2\", \"value\":\"V2\"} \
,{\"name\":\"A3\", \"value\":\"V3\"} \
]}'
file://policy.json
can someone please help me to fix this ?
Instead of submitting the content as Json you can just pass parameter as query parameters.
Try the following:
curl -X POST -ABC:token "https://jenkins_URL/buildWithParameters?\
ACTION=ONBOARD_NEWUSECASE&\
Name=ABC&\
Number=123456789&\
sample=SAMPLE&\
A1=V1&\
A2=V2&\
A3=V3"
I'm using groovy file with Jenkins to send a curl PUT request. I need to hide the --data in the request, but everytime I run the pipeline it shows the data.... I've tried with --silent and --output /dev/null , but the data still shows in the Jenkins Console Output.
Curl Request
String data = """{
"name": "$secretName",
"Description": "$secretName",
"value": "$secretValue"
}"""
sh """
curl --request PUT \
--silent \
--output /dev/null \
--insecure \
--location \
--url $host \
--header 'accept: application/json' \
--header "Authorization: Basic $API_KEY" \
--header 'content-type: application/json' \
--data '${data}'
"""
}
}
What I see in Jenkins console is:
curl --request PUT --silent --output /dev/null --insecure --location --url hostname --header accept: application/json --header Authorization: Basic **** --header content-type: application/json --data {
"name": "MY_ACTUAL_VALUE",
"Description": "MY_ACTUAL_VALUE",
"value": "MY_ACTUAL_VALUE" }
How can I hide this part:
--data {
"name": "MY_ACTUAL_VALUE",
"Description": "MY_ACTUAL_VALUE",
"value": "MY_ACTUAL_VALUE" }
If you store $secretName as a credential, Jenkins will automatically hide it for in the console output.
Best regards.
I try to launch a Jenkins build via its API using cURL:
#!/usr/bin/env bash
curl \
-i \
--fail \
--show-error \
-s \
-X POST \
-H 'Content-Type:application/json' \
-H 'Accept:application/json' \
--form json='{"parameter": [{"name":"COMPOSE_FULL_NAME", "value": "/redacted/docker-compose-prod.yml"}, {"name":"BRANCH", "value": "prod"}, {"name":"AD_USER", "value": "redacted"}, {"name":"AD_PASSWORD", "value": "redacted"}}]}' \
-u redactedUser:redactedToken \
-k \
https://jenkins-dck.redacted/job/elr-156344/job/stack_deploy/build \
and this is what I get:
curl: (22) The requested URL returned error: 400 Nothing is submitted
I tried several ways of passing POST data, like using -d or --data-urlencode 'json={ but with no success so far.
Any idea what's going on ? the message doesn't say much and I can't access the logs of the jenkins backend.
ok, found it, you first need to disregard the docs here: https://wiki.jenkins.io/display/JENKINS/Remote+access+API. The proper method is described at https://wiki.jenkins.io/display/JENKINS/Parameterized+Build
use this API endpoint:
https://jenkins-dck.redacted/job/elr-156344/job/stack_deploy/buildWithParameters?param1=urlencode¶m2=urlencoded
Don't forget to quote the url in the CURL quote, since bash will mess with & symbols.
working example:
#!/usr/bin/env bash
curl \
-i \
--fail \
--show-error \
-s \
-X POST \
-H 'Content-Type:application/json' \
-H 'Accept:application/json' \
-u redactedUser:redactedToken \
-k \
"https://jenkins-dck.redacted/job/elr-156344/job/stack_deploy/buildWithParameters?BRANCH=prod&AD_USER=$SERVICE_ACCOUNT"
I am trying to call a curl command with the sh command, but I would get "errors parsing JSON" no matter what I try.
sh """
curl -s -X POST \
--url www.example.com
--data \"{\'state\': \'failure\'}\"
"""
Problem:
I think you added terminators incorrectly.
Solution:
Simply use this format. It should work fine.
curl -s -X POST --header "Content-Type: application/json" \
--request POST \
--data '{"state":"failure"}' \
http://www.example.com
The JSON standard requires double quotes around key value pairs. Looks like in your example your missing a \ after the --url as well.
Try:
sh '''
curl -s -X POST \
-H \'Content-type: application/json\' \
--url www.example.com \
--data \'{"state": "failure"}\'
'''
If you end up needing to use String interpolation then
sh """
curl -s -X POST \
-H 'Content-type: application/json' \
--url www.example.com \
--data '{\"state\": \"status\"}'
"""