Jira curl issue create ends with error HTTP 415 - json

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"}

Related

Pass JSON as a value to a key to trigger gitlab pipeline

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

IFC conversionMethods "modern" and "v3" don't seem to be working

Good Day,
I'm trying to convert an IFC file using the "Revit engine".
I've tried conversionMethods "modern" and "v3".
https://forge.autodesk.com/en/docs/model-derivative/v2/reference/http/job-POST/
SVF2 Output > Formats > advanced
But the "Navisworks engine" is always used.
Here is the Request Header:
Content-Type: application/json
x-ads-derivative-format: fallback
x-ads-force: true
Authorization: Bearer ...
User-Agent: PostmanRuntime/7.29.0
Accept: */*
Cache-Control: no-cache
Postman-Token: 60ace5f6-a41c-4314-b3de-e2057f4f8795
Host: developer.api.autodesk.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 521
Cookie: PF=zlUuSLBAdPBYRrnJUXxwq1
Here is the Request Body:
{
"input": {
"urn": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bmVhbmV4LXN0YWdpbmcxLTE2MTk2MTgyOTM4MjMvMTY1NTIxOTY2OTY5MS1BQzIwLUZaSy1IYXVzLmlmYw"
},
"output": {
"destination": {
"region": "us"
},
"formats": [
{
"type": "svf2",
"views": [
"3d"
],
"advanced": {
"conversionMethod": "v3"
}
}
]
}
}
The Response:
{
"result": "success",
"urn": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bmVhbmV4LXN0YWdpbmcxLTE2MTk2MTgyOTM4MjMvMTY1NTIxOTY2OTY5MS1BQzIwLUZaSy1IYXVzLmlmYw",
"acceptedJobs": {
"output": {
"destination": {
"region": "us"
},
"formats": [
{
"type": "svf2",
"views": [
"3d"
],
"advanced": {
"conversionMethod": "v3"
}
}
]
}
}
}
And here is a snippet from the Manifest:
"name": "........ifc",
"progress": "complete",
"outputType": "svf2",
"properties": {
"Document Information": {
"Navisworks File Creator": "LcNwcLoaderPlugin:lcldifc",
"IFC Application Name": "ARCHICAD-64",
"IFC Application Version": "20.0.0",
"IFC Organization": "GRAPHISOFT",
"IFC Schema": "IFC4",
"IFC Loader": "3"
}
},
"status": "success"
Any ideas?
TIA
Wolfgang
It looks like you missed passing x-ads-force: true to the request header. Could you call the API like this way?
curl --location --request POST 'https://developer.api.autodesk.com/modelderivative/v2/designdata/job' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--header 'x-ads-force: true' \
--data-raw '{
"input": {
"urn": ""
},
"output": {
"formats": [
{
"type": "svf2",
"views": [
"3d"
],
"advanced": {
"conversionMethod": "v3"
}
}
]
}
}'
Everything works as designed, but the documentation is not clear on this issue.
The documentation says that the Revit IFC Loader is used for modern and V3:
Also, this blog post mentions that Revit will be used instead of Navisworks:
https://forge.autodesk.com/blog/model-derivative-ifc-pipeline-call-change
So you would expect that the external IDs in the properties to be Revit element IDs or uniqueIDs when using modern or V3.
But all IFC conversion methods are running on the Cloud version of Navisworks on Forge env.
Both modern and v3 IFC conversion methods or loaders are based on the Revit technics integrated with Navisworks, so they are called Revit-based IFC loaders.
You can see a similar thing on Navisworks Desktop.
You can check which conversion method was used in the Manifest (> "IFC Loader": "3").

No substitution in httpCustom payload

I would like to make a httpCustom payload in OCB but no replace info properly. I think i have tested all the ways i know but no results, someone who could help me. This is my code:
"notification": {
"httpCustom": {
"url": "http://xxxx.xxxx.xxxx:8080/api/v1/telemetry",
"payload": "[{ %22temperature%22: %22${id}%22, %22humidity%22: %22${humidity}%22, %22battery%22: %22${battery}%22 }]"
},
"attrs": [
"temperature","humidity","battery"
]
},
I have no error when i do subscription, but when i test in my end point no replace for the macros ${...}, the payload take object information compose but with no values.
I have test to write/send ${id} as then value of a field in payload and no substitution at all. Test it with URL encode and %22 and no success, I think could be disable substitution ? but i have check it and it has FALSE value.
This is a http response:
{
"method": "POST",
"path": "/",
"query": {},
"headers": {
"x-forwarded-for": "3.124.211.58",
"x-forwarded-proto": "https",
"x-forwarded-port": "443",
"host": "83efe9565d48d8bc8cf298d7786b8042.m.pipedream.net",
"x-amzn-trace-id": "Root=1-5f1bddce-7f2b4277458e77b98c0920d1",
"content-length": "54",
"user-agent": "orion/2.1.0 libcurl/7.29.0",
"fiware-service": "example",
"fiware-servicepath": "/example",
"accept": "application/json",
"content-type": "application/json",
"fiware-correlator": "a7fcfe32-ce47-11ea-9723-0242ac14000a",
"ngsiv2-attrsformat": "custom"
},
"bodyRaw": "[{ \"temperature\": \"\", \"humidity\": \"\", \"battery\": \"\" }]",
"body": [
{
"temperature": "",
"humidity": "",
"battery": ""
}
]
}
Orion VersiĆ³n: 2.1.0 and tested in 2.4.0
Any help ? Thanks in advance !!
I have done the following test, with Orion 2.4.0. Orion database is empty before starting the test.
First, create this subscription:
curl -v localhost:1026/v2/subscriptions -s -S -H 'Content-Type: application/json' -d #- <<EOF
{
"subject": {
"entities": [
{
"id": "Device1",
"type": "Device"
}
]
},
"notification": {
"httpCustom": {
"url": "http://localhost:1027/api/v1/telemetry",
"payload": "[{ %22temperature%22: %22\${id}%22, %22humidity%22: %22\${humidity}%22, %22battery%22: %22\${battery}%22 }]"},
"attrs": [
"temperature","humidity","battery"
]
}
}
EOF
Next, start a listining process at port 1027:
nc -l -p 1027
Next, create entity as follows (which triggers a notification):
curl localhost:1026/v2/entities -s -S -H 'Content-Type: application/json' -d #- <<EOF
{
"id": "Device1",
"type": "Device",
"temperature": {
"value": 23,
"type": "Number"
},
"humidity": {
"value": 99,
"type": "Number"
},
"battery": {
"value": 15,
"type": "Number"
}
}
EOF
What I get in nc is:
POST /api/v1/telemetry HTTP/1.1
Host: localhost:1027
User-Agent: orion/2.4.0 libcurl/7.52.1
Fiware-Servicepath: /
Accept: application/json
Content-Length: 65
Content-Type: text/plain; charset=utf-8
Fiware-Correlator: 4ae608b0-d248-11ea-81de-000c29df7908
Ngsiv2-AttrsFormat: custom
[{ "temperature": "Device1", "humidity": "99", "battery": "15" }]
which is the expected result, with replacements.
Next, restart the listening process and update the entity this way (triggering a new notification):
curl localhost:1026/v2/entities/Device1/attrs?options=forcedUpdate -s -S -H 'Content-Type: application/json' -d #- <<EOF
{
"temperature": {
"value": 32,
"type": "Number"
},
"humidity": {
"value": 79,
"type": "Number"
},
"battery": {
"value": 25,
"type": "Number"
}
}
EOF
and I get now in nc:
POST /api/v1/telemetry HTTP/1.1
Host: localhost:1027
User-Agent: orion/2.4.0 libcurl/7.52.1
Fiware-Servicepath: /
Accept: application/json
Content-Length: 65
Content-Type: text/plain; charset=utf-8
Fiware-Correlator: 66278dd8-d248-11ea-822d-000c29df7908
Ngsiv2-AttrsFormat: custom
[{ "temperature": "Device1", "humidity": "79", "battery": "25" }]
Conclusion: according my tests, Orion is working as expected.
I'd suggest to have a close look to the steps above and try to identify any possible diference comparing with your case. Note the \$ in the subscription creation payload: it is needed to avoid bash vars replacement in curl. Maybe you are facing a similar problem? You can check how your subscription is with GET /v2/subscriptions or checking directly in the database (csubs collection).

curl custom slack notifications from jenkins

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'

Docusign rest api composite template error

I've made composite templates and had them working before, but I'm suddenly getting an error and have no idea why this is causing an issue. Here's my request:
POST https://demo.docusign.net/restapi/v2/accounts/356019/envelopes HTTP/1.1
Host: demo.docusign.net
X-DocuSign-Authentication: <DocuSignCredentials><Username>test#gmail.com</Username><Password>*****</Password><IntegratorKey>****</IntegratorKey></DocuSignCredentials>
Content-Type: multipart/form-data; boundary=MY_BOUNDARY
Accept: application/json
Content-Length: 807319
Expect: 100-continue
Connection: Keep-Alive
--MY_BOUNDARY
Content-Type: application/json
Content-Disposition: form-data
{
"emailSubject": "Please Docusign this",
"emailBlurb": "This is a test... Also sign this form",
"enableWetSign": "true",
"status": "sent",
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "test#gmail.com",
"name": "test",
"recipientId": "1"
}
]
}
}],
"document":
{
"documentId": "1",
"name": "test0",
"fileExtension": "pdf"
}
}
]
}
--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="test0.pdf"; documentid="1"
<pdf bytes here>
--MY_BOUNDARY--
I have this working with server templates, but it seems like anything that requires the document object gives me a bad request. The request I'm getting is:
Request Error: BadRequestDocuSign Error: {
"errorCode": "UNSPECIFIED_ERROR",
"message": "the document is corrupt, rebuilding failed"
}
I've read the pdf bytes in another program and have successfully created a pdf from it, so I'm not sure what could be causing this issue. Does anybody know what the problem may be? Thank you for your time.