I'm trying to upload images on specific slack channel using Karate but no luck, I tried multiple times with different steps but still have 200 response and the image is not displayed in the channel.
Tried to post text content and successfully found the text on the channel.
Bellow are 2 of my tries following the Karate documentation:
#post
Feature: Post images
Background:
* url 'https://slack.com/api/files.upload'
* def req_params= {token: 'xxxxxxx',channels:'team',filename:'from Karate',pretty:'1'}
Scenario: upload image
Given path 'api','files'
And params req_headers
And multipart file myFile = { read: 'thumb.jpg', filename:
'upload-name.jpg', contentType: 'image/jpg' }
And multipart field message = 'image upload test'
And request req_headers
When method post
Then status 200
OR
Given path 'files','binary'
And param req_params
And request read('thumb.jpg')
When method post
Then status 200
Am I missing something? Tried the same examples found in Karate demo GitHub repository of uploading pdf and jpg but no luck.
Note: worked using Slack API UI.
You seem to be mixing up things, there is no need for a request body when you are using multipart. Your headers / params look off. Also based on the doc here, the name of the file-upload field is file. Try this:
Scenario: upload image
Given url 'https://slack.com/api/files.upload'
And multipart file file = { read: 'thumb.jpg', filename:
'upload-name.jpg', contentType: 'image/jpg' }
And multipart field token = 'xxxx-xxxxxxxxx-xxxx'
When method post
Then status 200
If this doesn't work, take the help of someone who can understand how to interpret the Slack API doc. Or get a Postman test working, then you'll easily figure out what you missed.
Related
I did some research both in the Postman GUI (auto-completion for request headers which does not offer "Content-Disposition") and in learning.postman.com/docs and there is no mention of "Content-Disposition" request header. I am using this request header in a POST request to upload a PDF file to an existing document. The operation is successful. But this is currently being done in a Jersey REST client Java project. I'm trying to create a similar POST REST request in Postman as part of a test collection.
Any workaround for this or just not supported? The "standard" multipart/form-data example cited everywhere and including Postman docs/examples is not supported by this upload POST API.
The Java/REST client code was based on this SO code: Upload file via streaming using Jersey 2 only difference in my client I am using "application/pdf" as MediaType.
I am struggling to get file upload on google cloud storage working with flutter.
We are using a PUT signed URL generated via https://cloud.google.com/storage/docs/samples/storage-generate-upload-signed-url-v4#storage_generate_upload_signed_url_v4-nodejs
On the Flutter side, when we make PUT with a multipart form request it ends up with "No Content" and failed to upload the file. We are adding a file to the request. as a multipart form.
final httpImage = http.MultipartFile.fromBytes('file', bytes,
contentType: MediaType.parse("image/png"),
filename: fileName);
and certainly blocked now with the implementation. Already tried to get a binary array from the file and posting file along with the policy but that did not work either.
I'm trying to replicate a post request done normally by a website form via postman but the server returns 500 error.
the form website URL that I'm dealing with is here.
what I have done so far is investigate the network request using chrome or safari dev tools, copy the request as cURL, import the cURL in postman and do the request.
what can be the possible reasons for the failure and what are the alternative ways to achieve the same result?
Postman Headers:
Most probably you must have used invalid request body. The browser shows parsed json body and you might have copied incomple request body.
To get full body click view source and copy the full content.
Hi Guys need your help.
I am creating an Image via docker REST API.
The link mentioned for parameter fromSrc following is the description :
fromSrc: Source to import. The value may be a URL from which the image can be retrieved or - to read the image from the request body. This parameter may only be used when importing an image.
if anyone can suggest the meaning of to read the image from the request body part and how we can test this
to read the image from the request body
means that you have to put your image as Json into the body of your request.
The URL, in this case, will look like this '.../images/create?fromSrc=-'
To test this, you can use Restlet client or Postman, which are chrome extensions that let you build a request with a body.
Does anyone has any example of Gmail Api resumable uploading(for attachments). I succeeded using the main upload for attachments up to 5 MB but I would like to send attachments over 30 MB.I cant use gmail SDK to everything needs to be in Rest Any suggestions?
Gmail API Resumable Upload
The steps for using resumable upload include:
Step 1: Start a resumable session
To initiate a resumable upload, make a POST or PUT request to the method's /upload URI and add the query parameter uploadType=resumable, for example:
POST https://www.googleapis.com/upload/gmail/v1/users/userId/messages/send?uploadType=resumable
For this initiating request, the body is either empty or it contains the metadata only; you'll transfer the actual contents of the file you want to upload in subsequent requests.
Step 2: Save the resumable session URI
If the session initiation request succeeds, the API server responds with a 200 OK HTTP status code. In addition, it provides a Location header that specifies your resumable session URI. The Location header, shown in the example below, includes an upload_id query parameter portion that gives the unique upload ID to use for this session.
Example: Resumable session initiation response
Here is the response to the request in Step 1:
HTTP/1.1 200 OK
Location: https://www.googleapis.com/upload/gmail/v1/users/userId/messages/send?uploadType=resumable&upload_id=xa298sd_sdlkj2
Content-Length: 0
Step 3: Upload the file
To upload the file, send a PUT request to the upload URI that you obtained in the previous step. The format of the upload request is:
PUT session_uri
Full code implementation sample is in the docs.
you need upload PUT method
but not binary body, only use multipart form body