The postman works in the below format to upload an attachment.
set method type to POST.
Then select Body -> form-data -> Enter your parameter name
and on right side next to value column, there will be dropdown "text, file", select File. choose your image file and post it:
I succeed with form-data, how do achieve via RAW text or Json because the image which is uploaded is dynamic.The image and txt file is stored in my local.
I am trying to upload png and .txt file to JIRA Rest endpoint(Subtask). My goal is create subtask, once subtask is created add attachment to it, attachment can be dynamic.
curl -X POST \
https://host/rest/api/3/issue/pos-14108/attachments \
-H 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
-H 'Postman-Token: c2b02ef1-4b81-4e8e-bb02-fb697bb2680e,1c20aa55-27c5-44c3-9f08-7efc41f25576' \
-H 'X-Atlassian-Token: no-check' \
-H 'cache-control: no-cache,no-cache' \
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
-F file=#/Users/nmane/Desktop/harry.png
According to this article on the Jira forums, to add an attachment, you should do the following:
curl -D- -u {username}:{password} -X POST -H "X-Atlassian-Token: nocheck" -F "file=#{path/to/file}" http://{base-url}/rest/api/2/issue/{issue-key}/attachments
according to Using curl to upload POST data with files
That fits with your comments and experiences, as far as I can tell.
I have not encountered anything about attaching files to a "raw" JSON request. The only way to do something like that would be to base 64 encode it (see Is it possible to attach file in POST Json? ) but I do not think that the Jira REST API supports it.
I hope that I have understood your issue correctly. if not, and you actually (for some reason) want to run everything from postman/newman, please update your question.
Related
I have added an attestation on google cloud platform to use for image signing and attestation by the attestor and want to remove the added attestation but I can't seem to find any documentation on how this is done or even if this is how is should be done.
I have seen the one for removal of the attestor but none on removing of deleting the attestation. I had added it using the following command:
Official documentation version:
gcloud container binauthz attestations create \
--project=$PROJECT_ID \
--artifact-url="${CONTAINER_PATH}#${DIGEST}" \
--attestor=${ATTESTOR} \
--signature-file=./signature.pgp \
--public-key-id="$KEY_FINGERPRINT"
Online tutorial version:
gcloud beta container binauthz attestations create \
--artifact-url="CONTAINER_PATH#DIGEST" \
--attestor=ATTESTOT_ID \
--attestor-project=PROJECT_ID \
--signature-file=./signature.pgp \
--pgp-key-fingerprint="KEY_FINGERPRINT"
but from a more recent documentation the --attestor should include the following --attestor="projects/${ATTESTOR_PROJECT_ID}/attestors/${ATTESTOR}" and unfortunately the tutorial I am following didn't use it this way and only added the attestor_id or name. So I want to remove this version and add new one but I am getting a conflict error
Resource in project [xxxx] is the subject of a conflict: occurrence ID "f5981e62-7b42-4f57-8486-b0d9518509fa" already exists in project
So how is it to be removed.
Update: documentation used to compare to online course: https://cloud.google.com/binary-authorization/docs/making-attestations
Looks like somekind of underlying resources(the error messages indicates that) are still need to be deleted.
Found some documentation on binary authorization where they have explained complete tear down and clean-up. It looks like apart from the attestor, we need to delete some other connected resources as well.
According to the official Google Cloud Documentation on Creating attestations and project occurrences DELETE REST API method documentation, I derived the curl command to delete a specific attestations:
curl "https://containeranalysis.googleapis.com/v1beta1/projects/${ATTESTATION_PROJECT_ID}/occurrences/${OCCURRENCES_GUID}" \
--request DELETE --header "Content-Type: application/json" \
--header "Authorization: Bearer $(gcloud auth print-access-token)"
Assuming the executing user has containeranalysis.occurrences.delete permission as included in roles/containeranalysis.occurrences.editor, the response would be 200 with an empty json. I am not sure if the following header is required but at the time of my testing it wasn't.
-H "X-Goog-User-Project: ${ATTESTATION_PROJECT_ID}"
I have provided feedback to Google Cloud documentation to include my curl command above at the official Google Cloud Documentation on Creating attestations
I have been working on uploading a simple XML file to a specialized Web Server. This webserver only supports the use of POST or GET, so it eliminates the use of CURLOPT_UPLOAD which only provides for PUT.
I can use the command line to send the file using the following command line
curl -H 'Content-Type: text/xml; charset=utf-8' -H 'SOAP Action:'
-T igs_meters2.xml -X POST //url//
I tried to use CURLOPT_POST and CURLOPT_READDATA, but received a 413 Request Entity Too Large.
I know this cannot be this hard, but I am out in areas I have never work in. Thanks in advance for an idea.
SOLVED:
the tip about CUSTOMREQUEST was what I needed to find. That helped, and I also needed to add in an HTTPHEADER for CONTENT-TYPE and SOAPAction:
I'm trying to post a request using curl to my es cluster in AWS using my accessKey and secretKey. I have successfully done this through postman (details here) where you can specify AWS credentials but I would like to make this work with curl. Postman can auto-generate your curl request for you but all I get are errors.
This is the generated curl request along with the response
curl -X GET \
https://search-00000000000001.eu-west-1.es.amazonaws.com/_cat/indices \
-H 'Authorization: AWS4-HMAC-SHA256 Credential=11111111111111111111/20181119/eu-west-1/es/aws4_request, SignedHeaders=cache-control;content-type;host;postman-token;x-amz-date, Signature=11111111116401882398f46011f14fdb9d55e012a4fb912706d67c1111111111' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Host: search-00000000000001.eu-west-1.es.amazonaws.com' \
-H 'Postman-Token: 00000000-0000-4001-8006-9291e208a000' \
-H 'X-Amz-Date: 20181119T220000Z' \
-H 'cache-control: no-cache'
{"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."}%
IDs have been changed to protect the innocent.
I have checked all my keys and region, and like i said this works through postman. Is it possible to access this AWS service using my keys through curl?
This is quite a long rabbit hole. Thanks to Adam for the comment that sent me in the correct direction. The link https://docs.aws.amazon.com/apigateway/api-reference/signing-requests/ really helps you understand what you need to do.
I've since found a script that follows the signing requests method outlined above. It runs in bash and whilst it is not written for use with elasticsearch requests it can be used for them.
https://github.com/riboseinc/aws-authenticating-secgroup-scripts many thanks to https://www.ribose.com for putting this on github.
If your host contains ':443' remove it and try again.
This worked for me.
"My initial problem: If I access it with Postman using the same url, I get the same error, but removing the ‘:443/’, it works fine, so it’s nothing wrong with the key and secret I’m using."
I'm using the curl api from http://curl.haxx.se/ in a c++ application. I'm trying to write the equivalent of:
curl -v -X POST -H "Content-type: application/json; charset=utf-16" --data-binary #some data.json
I'm using curl_easy_setopt() to set up the various options but the bit I can't figure out is the --data-binary flag. Which CURLOPT setting would I use to set this?
Thanks in advance
You should use CURLOPT_POSTFIELDS:
specify data to POST to server [...] Pass a char * as parameter, pointing to the full data to send in a HTTP POST operation. You must make sure that the data is formatted the way you want the server to receive it.
Note: you can easily discover this by using the --libcurl option:
--libcurl FILE Dump libcurl equivalent code of this command line
I am looking for a RESTful web service to which I can send a document (doc, docx, xls, xlsx, ppt, pptx, and tiff at a minimum) for conversion to pdf and swf.
The reason I need swf in addition to pfd is so that I can display the document in the browser using a flash-based document viewer such as FlexPaper.
I basically want transloadit.com for documents.
One option is to use the Scribd API, download the pdf, and use swftools to convert the pdf to swf. However I am interested in alternatives.
doxument.com might be what you looking for. They do offer some kind of REST API. I'm not sure about the formats though.
I am developing on http://webservices.io which is in beta and offers document conversion via a REST API.
While it also doesn't do all the conversions you are asking for, it does have docx and xlsx support. See matrix with supported conversions
Aspose library is best of the best http://www.aspose.com/ Use it for create your own service
Although it's an old question, however just want to share another solution for future reference.
GroupDocs.Conversion Cloud REST API is another option to convert back and forth between over 65+ types of documents and images, including all Microsoft Office and OpenDocument file formats, PDF documents, HTML, CAD, raster images and much more.
cURL sample Code:
### Retrieve access token
### TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
curl --request POST https://api.groupdocs.cloud/connect/token
--header "Content-Type: application/x-www-form-urlencoded"
--data "grant_type=client_credentials&client_id=[APP_SID]&client_secret=[APP_KEY]"
### Convert and Add Watermark
curl --request POST "https://api.groupdocs.cloud/v2.0/conversion"
--header "authorization: Bearer [ACCESS_TOKEN]"
--header "accept: application/json"
--header "Content-Type: application/json" --data "{ "FilePath": "test_doc.docx", "Format": "pdf", "ConvertOptions": { "FromPage": 1, "PagesCount": 1, "WatermarkOptions": { "text": "Watermark" } }, "OutputPath": "Output"}"
I work with Aspose as developer evangelist.