I am trying to trigger a gitlab pipeline with the below payload. I am passing JSON as a value to a predefined variable (wwww) .
{
"ref": "test_branch",
"variables": [
{"key": "xxx", "value": "abc"},
{"key": "yyyy", "value": "def"},
{"key": "zzzz", "value": "ghi"},
{"key": "wwww", "value": "{"test1" : "test2"}"}
]
}
If I trigger the gitlab pipeline with the above payload it fails with below error
curl --request POST --header PRIVATE-TOKEN: xxxxxxxxx --header Content-Type: application/json --data #sample.json https://gitlab.example.com/api/v4/projects/12345/pipeline
curl: (6) Could not resolve host: xxxxxxxxx
curl: (6) Could not resolve host: application
{"error":"The provided content-type '' is not supported."}
I know the above payload is incorrect. Can someone help with the correct method to pass JSON to a key
Related
I am trying to create issue in project via curl, but it ends with 415 error which I don't know why as I am pasting only text there.
curl -D- -s -u email:api_key -X POST --data "{\"fields\":{\"project\":{\"key\": \"PROBLEM\"},\"summary\": \"REST ye merry gentlemen.\",\"description\": \"Creating of an issue using project keys and issue type names using the REST API\",\"issuetype\": {\"name\": \"Outage\"}}}" https://company.atlassian.net/rest/api/2/issue/
Output:
HTTP/2 415
date: Tue, 27 Sep 2022 11:14:10 GMT
content-type: text/html;charset=UTF-8
server: globaledge-envoy
timing-allow-origin: *
x-arequestid: bbc0506d-8e7c-442f-a180-46632081b6a5
set-cookie: atlassian.xsrf.token=BAHL-ME69-JQ45-BS4O_929b97ddce3a4de2b40abbd3d2817ff133d29cee_lin; path=/; SameSite=None; Secure
x-aaccountid: 62b303db84d73c7201680c55
x-envoy-upstream-service-time: 56
expect-ct: report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/atlassian-proxy", max-age=86400
strict-transport-security: max-age=63072000; preload
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
atl-traceid: b0b3324454c29763
report-to: {"endpoints": [{"url": "https://dz8aopenkvv6s.cloudfront.net"}], "group": "endpoint-1", "include_subdomains": true, "max_age": 600}
nel: {"failure_fraction": 0.001, "include_subdomains": true, "max_age": 600, "report_to": "endpoint-1"}
vary: Accept-Encoding
I don't understand why I am getting 415 message from Jira.
HTTP 415 means Unsupported Media Type (https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/415).
Basically, you have to tell JIRA you are sending a JSON. Just add:
-H 'Content-Type: application/json'
to your curl command.
Also another note you may want to use
rest/api/3/issue/ instead of rest/api/2/issue/
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-createmeta-get
and if you got some error message like:
Operation value must be an Atlassian Document (see the Atlassian Document Format)
change your "description" field to something like this:
"description": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Creating of an issue using project keys and issue type names using the REST API"
}
]
}
]
}
For example
curl -i -u nanana#gmail.com:xxxxxx -H 'Content-Type: application/json' -XPOST --data '{"fields": {"project": {"key": "RW"}, "summary": "REST ye merry gentlemen.", "description": {"type": "doc", "version": 1, "content": [{"type": "paragraph", "content": [{"type": "text", "text": "Creating of an issue using project keys and issue type names using the REST API"} ] } ] }, "issuetype": {"name": "Task"} } }' https://s50600822.atlassian.net/rest/api/3/issue
{"id":"10013","key":"RW-6","self":"https://s50600822.atlassian.net/rest/api/3/issue/10013"}
So I have this code to write out a json file to be connected to via endpoint. The file is pretty standard in that it has the location of how to connect to the endpoint as well as some data.
%%writefile default-pred.json
{ PROJECT_ID:"msds434-gcp",
REGION:"us-central1",
ENDPOINT_ID:"2857701089334001664",
INPUT_DATA_FILE:"INPUT-JSON",
"instances": [
{"age": 39,
"bill_amt_1": 47174,
"bill_amt_2": 47974,
"bill_amt_3": 48630,
"bill_amt_4": 50803,
"bill_amt_5": 30789,
"bill_amt_6": 15874,
"education_level": "1",
"limit_balance": 50000,
"marital_status": "2",
"pay_0": 0,
"pay_2":0,
"pay_3": 0,
"pay_4": 0,
"pay_5": "0",
"pay_6": "0",
"pay_amt_1": 1800,
"pay_amt_2": 2000,
"pay_amt_3": 3000,
"pay_amt_4": 2000,
"pay_amt_5": 2000,
"pay_amt_6": 2000,
"sex": "1"
}
]
}
Then I have this trying to connect to the file and then taking the information to connect to the end point in question. I know the information is right as it's the exact code from GCP.
!curl \
-X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://us-central1-prediction-aiplatform.googleapis.com/v1alpha1/projects/$PROJECT_ID/locations/$REGION/endpoints/$ENDPOINT_ID:predict \
-d "#default-pred.json"
So from the information I have I would expect it to parse the information I have and connect to the endpoint, but obviously I have my file wrong somehow. Any idea what it is?
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"PROJECT_ID\": Cannot find field.\nInvalid JSON payload received. Unknown name \"REGION\": Cannot find field.\nInvalid JSON payload received. Unknown name \"ENDPOINT_ID\": Cannot find field.\nInvalid JSON payload received. Unknown name \"INPUT_DATA_FILE\": Cannot find field.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"PROJECT_ID\": Cannot find field."
},
{
"description": "Invalid JSON payload received. Unknown name \"REGION\": Cannot find field."
},
{
"description": "Invalid JSON payload received. Unknown name \"ENDPOINT_ID\": Cannot find field."
},
{
"description": "Invalid JSON payload received. Unknown name \"INPUT_DATA_FILE\": Cannot find field."
}
]
}
]
}
}
What am I missing here?
The data file should only include the data.
You've included PROJECT_ID, REGION, ENDPOINT and should not.
These need to be set in the (bash) environment before you issue the curl command:
PROJECT_ID="msds434-gcp"
REGION="us-central1"
ENDPOINT_ID="2857701089334001664"
curl \
--request POST \
--header "Authorization: Bearer $(gcloud auth print-access-token)" \
--header "Content-Type: application/json" \
https://us-central1-prediction-aiplatform.googleapis.com/v1alpha1/projects/$PROJECT_ID/locations/$REGION/endpoints/$ENDPOINT_ID:predict \
--data "#default-pred.json"
The file default-pred.json should probably (I can never find this service's methods in APIs Explorer!) just be:
{
instances": [
{ "age": 39,
"bill_amt_1": 47174,
"bill_amt_2": 47974,
"bill_amt_3": 48630,
"bill_amt_4": 50803,
"bill_amt_5": 30789,
"bill_amt_6": 15874,
"education_level": "1",
"limit_balance": 50000,
"marital_status": "2",
"pay_0": 0,
"pay_2":0,
"pay_3": 0,
"pay_4": 0,
"pay_5": "0",
"pay_6": "0",
"pay_amt_1": 1800,
"pay_amt_2": 2000,
"pay_amt_3": 3000,
"pay_amt_4": 2000,
"pay_amt_5": 2000,
"pay_amt_6": 2000,
"sex": "1"
}
]
}
See the documentation for the aiplatform predict method as this explains this.
I am trying to send an custom slack notification to my slack channel using curl. Below my payload . Using curl to post notifications to Slack channel so that Team members could be able to see the Verison, s3 link and Directly they can access directly. Any suggestions or inputs would be greatly appreciated.
version=1.2.4
bundleversion=1.3.4.5
SLACK_MSG="Version=$version bundleversion=$bundleversion s3link:Random "
curl -H "Content-type: application/json" -X POST --data-urlencode -d
"payload='{
"username": "Kalyan",
"attachments": [
{
"color": "danger",
"fields": [
{
"title": "Danger Event",
"text": "$SLACK_MSG",
"short": false
}
]
},
{
"color": "warning",
"fields": [
{
"title": "Warning Event",
"value": "This is a warning",
"short": false
}
]
},
{
"color": "good",
"fields": [
{
"title": "Good Event",
"value": "This is good",
"short": false
}
]
}
]
}'" https://hooks.slack.com/services/XXXXXX/XXXXXXX/XXXXXXXXXX
Below Jenkins Error
curl: (3) [globbing] nested brace in column 51
curl: (3) Illegal characters found in URL
curl: (6) Could not resolve host: bundleversion=1.3.4.5
curl: (3) Port number ended with 'R'
curl: (3) [globbing] unmatched close brace/bracket in column 52
curl: (3) Illegal characters found in URL
curl: (6) Could not resolve host: is
curl: (6) Could not resolve host: a
curl: (3) Illegal characters found in URL
curl: (6) Could not resolve host: is
curl: (3) [globbing] unmatched close brace/bracket in column 56
Any inputs Greatly Appreciated.
Your first danger attachment has a field with an invalid property called text specified - change this property to value to make it into a valid Slack field.
You can troubleshoot Slack message payloads via the Slack Message Formatting page to see if they are valid: here's the corrected message payload.
I will also make it simple:
Please note: There should not be any space after "content-type:" and "application/json" people do that mistake.
and take care about backslash. You can also try this on terminal/cmd. I should work
curl -X POST -H "Content-type:application/json" --data '{\"text\":\"here_is_your_message\"}' YOUR_WEBHOOK_URL
try this: payload and curl for custom slack notification.
I used that in Gitlab-CI.yml file for sending Job artifacts and reports to Slack. It works fine.
The code below you can modify because I wrote that like it appears Green/Red when job Pass or Fail.
- 'curl -H "Content-Type:application/json" -X POST --data "{
\"attachments\": [
{
\"mrkdwn_in\": [\"text\"],
\"color\": \"#36a64f\",
\"author_name\": \"<https://$Gitlab_Home_URL/${GITLAB_USER_LOGIN}|${GITLAB_USER_NAME}>($GITLAB_USER_LOGIN)\",
\"text\": \"*Job <https://$REPO_URL/-/jobs/${CI_JOB_ID}|TESTING> was SUCCESSFUL in pipeline <https://$REPO_URL/pipelines/${CI_PIPELINE_ID}|${CI_PIPELINE_ID}>*\",
\"fields\": [
{
\"title\": \"Trigger source\",
\"value\": \"$CI_PIPELINE_SOURCE\",
\"short\": true
},
{
\"title\": \"Branch\",
\"value\": \"<https://$REPO_URL/tree/$CI_COMMIT_REF_NAME|$CI_COMMIT_REF_NAME>\",
\"short\": true
},
{
\"title\": \"Commit message\",
\"value\": \"<https://$REPO_URL/commit/${CI_COMMIT_SHA}|$CI_COMMIT_TITLE>\",
\"short\": true
}
],
\"footer\": \"<https://$REPO_URL|$CI_PROJECT_NAME>\",
\"footer_icon\": \"https://www.stickpng.com/assets/images/5847f997cef1014c0b5e48c1.png\",
}
]
}" YOUR_SLACK_WEBHOOK'
Im trying to index a simple json data in solr using curl. When i use the command, it says
"curl -X POST -H 'Content-Type:application/json'-d http://localhost:8983/solr/informationretrieval/update/json/docs '[{"id":"1","title":"Doc 1"},{"id":"2","title":"Doc 2"}]'
{"responseHeader":{"status":0,"QTime":1}}
curl: (3) [globbing] bad range specification in column 3"
I have tried removing quotes, tried -g and --globoff etc but every time there are errors like illegal port number. Can anyone please help?
Adding Multiple JSON Documents
curl -X POST -H 'Content-Type: application/json' 'http://localhost:8983/solr/informationretrieval/update' --data-binary '
[
{
"id": "1",
"title": "Doc 1"
},
{
"id": "2",
"title": "Doc 2"
}
]'
I'm trying to send commands to the Orion Context Broker using iotagent-ul with HTTP protcol.
Context Broker and IoT Agent are in different servers (actually IoTA is in running in my laptop).
I've configured the necessary parameters in config.js file.
My request is as follows:
curl -L POST -H "Fiware-Service: myHome" -H "Fiware-ServicePath: /environment" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
"devices": [
{
"device_id": "sensor01",
"entity_name": "LivingRoomSensor",
"entity_type": "multiSensor",
"attributes": [
{ "object_id": "t", "name": "Temperature", "type": "celsius" },
{ "object_id": "l", "name": "Luminosity", "type": "lumens" }
]
}
]
}
' 'http://localhost:4061/iot/devices'
It shows the following erros:
In IoTA terminal:
time=2017-02-14T15:06:14.832Z | lvl=ERROR | corr=88ed3729-6682-44ce-9b0a-28098e54c94e | trans=88ed3729-6682-44ce-9b0a-28098e54c94e | op=IoTAgentNGSI.DomainControl | srv=myHome | subsrv=/environment | msg=TypeError: Cannot read property 'findOne' of undefined | comp=IoTAgent
In "cURL terminal":
curl: (52) Empty reply from server
Please can you tell us what's the IoT Agent UL version you are using?
On the other hand, it seems you are missing the 'protocol' field in the payload, please check
http://fiwaretourguide.readthedocs.io/en/latest/connection-to-the-internet-of-things/how-to-read-measures-captured-from-iot-devices/
best