yuuvis® RAD Q&A

+1 vote
by (790 points)

Hello dear enaio-development Team,

We would like to push updates for our microservices from the build-pipeline with, for instance, curl. This should be possible with a post request with multipart/form-data content-type to the /manage/apps/sam

The curl command may look like this:
curl -X POST -F data=@path_to_json -F @path_to_microservice.jar 'http://yourserver/manage/apps/sam'

The json file contains a single line: {"command": "update"}

Such Post-Requests from Postman work, but curl or Invoke-WebRequest (Powershell cmdlet) return 415 (see below)

Servicewatcher API Swagger also throws an error:

{
"timestamp": 1547647004842,
"status": 415,
"error": "Unsupported Media Type",
"exception": "org.springframework.web.HttpMediaTypeNotSupportedException",
"message": "Content type 'application/octet-stream' not supported",
"path": "/manage/apps/sam"
}

Could you please help with this?

Best wishes,
Umar

2 Answers

+2 votes
by (790 points)
 
Best answer

The answer Christian gave, helped me to solve the issue. The problem is, that if the content-type is not specified, curl will try to guess it from the file extension, or use the previously specified type (from an earlier file if several files are specified in a list) or else it will use the default type 'application/octet-stream'.

The solution is quite simple. You need to specify the type for every file you want to upload, like this:

curl -X POST -F data=@path_to_json;type=application/json -F @path_to_microservice.jar;type=application/json 'http://yourserver/manage/apps/sam'
+2 votes
by

Hi Umar,
the endpoint /manage/apps/sam dont support "application/octet-stream". I think you have to set a header with curl. May be application/json is the default in postman, I am not sure. But you can try this:
curl --header "Content-Type: application/json" ...

See here: https://stackoverflow.com/questions/7172784/how-to-post-json-data-with-curl-from-terminal-commandline-to-test-spring-rest

Related questions

...