I am trying to create a collection that will upload images and be able to run it in multiple iterations and want to use newman to run it.
For our API it only supports uploading images through using binary data.
https://www.getpostman.com/docs/requests
- Postman does not support saving the files for both form-data and binary.
https://www.getpostman.com/docs/run_file_post_requests - They show how you can upload images with Newman using form-data, but not for binary.
Is it possible to use newman with binary image upload?
here is what you need in your request. I had to modify the src from the saved collection
{
"name": "Room Document",
"request": {
"url": "{{url}}/api/v1/folders/321/documents",
"method": "POST",
"header": [
{
"key": "Accept",
"value": "application/json",
"description": ""
},
{
"key": "Authorization",
"value": "3242349-324432-23423423-23424",
"description": ""
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"type": "file",
"src": "blank.pdf"
}
]
},
"description": " "
},
"response": []
},
I used it like this which worked with the binary:
"body": {
"mode": "file",
"file": {
"src": "path/to/your/file.jpg"
}
}
That way you dont have to set the KEY, Type and so on. But you need to set it within the Header as
Content-Disposition: attachment; filename="file.jpg"
and in our case with
Content-Type: application/octet-stream
Related
Using test listing information I'm trying to send a http put request to eBay using powerautomate. To set up my HTTP action I've followed the API instructions for the createOrReplaceInventoryItem action.
Ebay API Documentation
I continue to get the below error:
{"errors":[{"errorId":25709,"domain":"API_INVENTORY","subdomain":"Selling","category":"REQUEST","message":"Invalid
value for header Content-Language."}]}
I have read many articles where they have suggested changing Content-Language to Accepted-Language but that has not resolved the issue. Another article said to assign it to the HTTPContent instance but I'm unaware how to do this within powerapps.
Link to Suggestion on this thread
Here is the Request:
{
"uri": "https://api.ebay.com/sell/inventory/v1/inventory_item/TestMonkey",
"method": "PUT",
"headers": {
"Authorization": "*sanitized*",
"Content-Language\t": "en_US",
"Content-Type": "application/json",
"X-EBAY-C-MARKETPLACE-ID": "EBAY_US"
},
"body": {
"availability": {
"shipToLocationAvailability": {
"quantity": 50
}
},
"condition": "NEW",
"product": {
"title": "GoPro Hero4 Helmet Cam",
"description": "New GoPro Hero4 Helmet Cam. Unopened box.",
"aspects": {
"Brand": [
"GoPro"
],
"Type": [
"Helmet/Action"
],
"Storage Type": [
"Removable"
],
"Recording Definition": [
"High Definition"
],
"Media Format": [
"Flash Drive (SSD)"
],
"Optical Zoom": [
"10x"
]
},
"brand": "GoPro",
"mpn": "CHDHX-401",
"imageUrls": [
"https://coolbackgrounds.io/images/backgrounds/white/pure-white-background-85a2a7fd.jpg"
]
}
}
How should I configure the Content-Language header value in powerautomate?
Thank you in advance.
I am using ASP.NET Core 3.0 (<TargetFramework>netcoreapp3.0</TargetFramework>) and Swashbuckle 5.0.0-rc4 (<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc4" />).
I have an API Controller Action Method which accepts an uploaded file (that is, an IFormFile) and some metadata and tags to associate with the POSTed file:
public async Task<IActionResult> Post(
string fileId = null,
IFormFile file = null,
[FromForm] IDictionary<string, object> metadata = null,
[FromForm] IEnumerable<string> tags = null)
{
// ...
}
I am able -- through sheer luck -- to get Swashbuckle/swagger-ui to send the metadata in a format that seems to be correct (except, I need to write something that will parse out the JSON from within the multipart/form-data fragment). The metadata parameter is OK.
I am having real problems with the tags parameter. The OpenAPI document generated by Swashbuckle is like this:
"/projects/{projectId}/features/imports": {
"post": {
"tags": [
"FeaturesImports"
],
"summary": "Import features from a file uploaded by the end user, or from a file already stored in XXX",
"parameters": [
{
"name": "fileId",
"in": "query",
"description": "The XXX File (Version) Id of the source file to import. Optional; if file is not provided, a fileIdmust be provided.",
"schema": {
"type": "string"
}
},
{
"name": "projectId",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"file": {
"type": "string",
"format": "binary"
},
"metadata": {
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": false
}
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"encoding": {
"file": {
"style": "form"
},
"metadata": {
"style": "form"
},
"tags": {
"style": "form"
}
}
}
}
},
To my eyes, the fact that we have:
"tags": {
"type": "array",
"items": {
"type": "string"
}
seems correct: I want to receive an array of strings.
However, when the swagger-ui renders the form, and the end user enters the required data, the submitted request is not as I would would expect. I would expect the tags data to be something like:
------WebKitFormBoundaryKQWA8MEJTEXgMvsj
Content-Disposition: form-data; name="metadata"
{
"additionalProp1": {},
"additionalProp2": {},
"additionalProp3": {}
}
------WebKitFormBoundaryKQWA8MEJTEXgMvsj
Content-Disposition: form-data; name="tags"
["string1","string2",",","string4\""]
------WebKitFormBoundaryKQWA8MEJTEXgMvsj--
but what I end up getting is:
------WebKitFormBoundaryKQWA8MEJTEXgMvsj
Content-Disposition: form-data; name="metadata"
{
"additionalProp1": {},
"additionalProp2": {},
"additionalProp3": {}
}
------WebKitFormBoundaryKQWA8MEJTEXgMvsj
Content-Disposition: form-data; name="tags"
string1,string2,,string4"
------WebKitFormBoundaryKQWA8MEJTEXgMvsj--
The problems with this are:
the when the data is bound to the Action Method's parameters, the IEnumerable<string> tags parameter only contains one string, and not the 4 I would expect
the individual strings are joined, using a comma; and any commas present in the "raw" strings are not escaped. It is therefore impossible to reconstruct the original intended data
Given the metadata parameter appears to be JSON encoded, I would expect the same for the tags parameter. However, the OpenAPI 3.0.2 spec says (at https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#special-considerations-for-multipart-content) that,
If the property is complex, or an array of complex values, the default Content-Type is application/json
... so that explains the JSON encoding of the metadata parameter, and...
If the property is a primitive, or an array of primitive values, the default Content-Type is text/plain
... ah, and that explains the encoding of the tags parameter, since it is an array of primitive values.
I think the underlying problem is that swagger-ui does not yet support the "Encoding Object" that can be set for multipart parameters, but does anyone have any suggestions, tips, workarounds or other ideas that might be helpful here?
I am trying to add a specific key, value to the body of a request via Karate as x-www-form-urlencoded
The last "And request" in the example fails.
Via Postman, I have created an working example which gives us the correct response. (exported the mainpart below)
"item": [
{
"name": "http://www.google.com/api",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/x-www-form-urlencoded",
"type": "text"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "our_xml",
"value": "<create_stuff> .... XML .... </create_stuff>",
"type": "text"
Scenario: XXX
Given url 'http://www.google.com/api'
And header Content-Type = 'application/x-www-form-urlencoded'
And request{"our_xml" : read('classpath:xml/post.xml')
I think you missed the existence of form field: https://github.com/intuit/karate#form-field - header will be set automatically.
* form field key = 'our_xml'
* form field value = read('classpath:xml/post.xml')
Running a Postman API using Newman command which currently uploads a single file. My requirement is to upload multiple files using this same API.
My current code which uploads a single file looks like this:-
"method": "POST",
"header": [],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"description": "Jpeg image or video (mov or mp4)",
"type": "file",
"src": "C:\\Test\\abc.jpeg"
}
]
}
In this very same code, I want to upload multiple files.
Need some direction on how can I achieve it.
I post multi file in postman/newman by sending multi POST requests - one file per request.
So you can send many files executing one postman collection of requests.
Edit:
Example of form with 2 file field:
"method": "POST",
"header": [],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "myFile1",
"description": "Jpeg image or video (mov or mp4)",
"type": "file",
"src": "C:\\Test\\abc.jpeg"
},
{
"key": "myFile2",
"description": "Jpeg image or video (mov or mp4)",
"type": "file",
"src": "C:\\Test\\def.jpeg"
}
]
}
I am referring information on following url.
https://ibm-public-cos.github.io/crs-docs/about-compatibility-api#operations-on-buckets
As mentioned in above URL,there are 3 Objects related IBM cloud storage object API which are accessible.However,some APIs of IBM CSO API are not accessible e.g. PUT Bucket ACL & GET Bucket ACL and getting 403 error message while accessing them with POSTMAN.I need information that how can we access these APIs? Please provide any information related to it.
Any help is greatly appreciated.
As of today, GET/PUT Bucket ACL are supported in IBM COS. If you are using Postman, here's an example of a Postman dump for these (obviously you'll need to calculate the Authorization header and use all of your own info, this is just an educational sample):
{
"version": 1,
"collections": [
{
"id": "ab20b534-025a-4be2-b90f-a980d4a81632",
"name": "Operations on buckets",
"folders": [],
"requests": [
{
"id": "b89a66a4-0183-43cf-9712-7c07ba615b0b",
"url": "http://endpoint/bucket-name?acl=",
"method": "PUT",
"collectionId": "ab20b534-025a-4be2-b90f-a980d4a81632",
"name": "Add a bucket ACL (canned)",
"description": "",
"headers": "x-amz-date: {timestamp}\nAuthorization: {authorization-string}\nx-amz-acl: public-read\nContent-Type: text/plain",
"dataMode": "raw",
"data": ""
},
{
"id": "df2a9b2a-d66b-4ea6-8cfb-ab341ec23bc2",
"url": "http://endpoint/bucket-name?acl=",
"method": "PUT",
"collectionId": "ab20b534-025a-4be2-b90f-a980d4a81632",
"name": "Add a bucket ACL (custom)",
"description": "",
"headers": "x-amz-date: {timestamp}\nx-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\nAuthorization: {authorization-string}\nContent-Type: text/plain; charset=utf-8",
"dataMode": "raw",
"data": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<AccessControlPolicy xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">\n <Owner>\n <ID>d4d11b981e6e489486a945d640d41c4d</ID>\n <DisplayName>OwnerDisplayName1</DisplayName>\n </Owner>\n <AccessControlList>\n <Grant>\n <Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"CanonicalUser\">\n <ID>d4d11b981e6e489486a945d640d41c4d</ID>\n <DisplayName>some-name</DisplayName>\n </Grantee>\n <Permission>FULL_CONTROL</Permission>\n </Grant>\n <Grant>\n <Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"CanonicalUser\">\n <ID>a5c26620b0704967a72d7aeb90cf57b2</ID>\n <DisplayName>some-name</DisplayName>\n </Grantee>\n <Permission>WRITE</Permission>\n </Grant>\n </AccessControlList>\n</AccessControlPolicy>"
},
{
"id": "7f79523f-b9aa-46ad-abda-9ad7e37d3980",
"url": "http://bucket-name.endpoint/?acl=",
"method": "GET",
"collectionId": "ab20b534-025a-4be2-b90f-a980d4a81632",
"name": "Get a bucket ACL",
"description": "",
"headers": "x-amz-date: {timestamp}\nAuthorization: {authorization-string}\nContent-Type: text/plain",
"dataMode": "raw",
"data": ""
}
],
"order": [
"b89a66a4-0183-43cf-9712-7c07ba615b0b",
"df2a9b2a-d66b-4ea6-8cfb-ab341ec23bc2",
"7f79523f-b9aa-46ad-abda-9ad7e37d3980"
]
}
],
"environments": [
{
"id": "fa619322-0a84-47b5-958b-84fa4a6286ba",
"name": "API-Flow Imports",
"values": [],
"timestamp": 1497532748923
}
]
}
Based on your reference to the 'Cloud Storage Object API', I can guess you might be working with an on-premises installation of IBM COS. Please send me an email at nicholas.lange[at]ibm.com so we can discuss what you are looking for.