Solved

curl command in shell

  • 10 May 2023
  • 4 replies
  • 162 views

Hi Team 

 

I need to post file1.json and file2.csv using curl.

I tried this but no luck

Please help me

 

 

metadata=@/tmp/file1.json \
files=@/tmp/file2.csv \
curl -kiv --trace -w --location --request POST "<Location>" \
--header "accept:application/json,application/hal+json, application/json, application/*+json, text/plain, application/octet-stream, application/xml, text/xml, application/x-www-form-urlencoded, application/*+xml, multipart/form-data, multipart/mixed, */*" \
--header "Accept-Charset: UTF-8" \
--header "Content-Type:application/json" \
--form  metadata="$metadata" \
--header "Accept-Charset: UTF-8" \
--header "Content-Type:multipart/form-data,text/csv" \
--form  files="$files"

icon

Best answer by Bikram 10 May 2023, 23:18

View original

4 replies

Userlevel 5
Badge +1

@Priyanka Mynepally 

Can you please provide the errors you are getting while trying to post data .

I am also not seeing the destination where you want to post the file into it.

Curl basic command for post is like this .

I will give a try inn my local system and will let you know if i get any lcuk on it.

curl -X POST -H "Content-Type: application/json" -d @/path/to/file.json http://example.com/api/endpoint

Hi Bikram

Error is like 415

{"timestamp":"2023-05-10T07:34:17.071+00:00","status":415,"error
0040: ":"Unsupported Media Type","message":"","path":"/v1/files"}
== Info: Closing connection 0

and content is becoming application/octet-stream

 

Is there any property we can change to make server undersatnd text/csv and application/json files?

@Priyanka Mynepally

Can you please provide the errors you are getting while trying to post data .

I am also not seeing the destination where you want to post the file into it.

Curl basic command for post is like this .

I will give a try inn my local system and will let you know if i get any lcuk on it.

curl -X POST -H "Content-Type: application/json" -d @/path/to/file.json http://example.com/api/endpoint

Hi Bikram

Error is like 415

{"timestamp":"2023-05-10T07:34:17.071+00:00","status":415,"error
0040: ":"Unsupported Media Type","message":"","path":"/v1/files"}
== Info: Closing connection 0

and content is becoming application/octet-stream

 

Is there any property we can change to make server undersatnd text/csv and application/json files?

Userlevel 5
Badge +1

@Priyanka Mynepally 

I tried below for json file load and its working for me .

 

curl -X 'POST' \
  'https://file.io/' \
  -H 'accept: application/json' \
  -H 'Content-Type: multipart/form-data' \
  -F 'file=@/Users/bikramrout/a.json;type=application/json' \
  -F 'expires=' \
  -F 'maxDownloads=' \
  -F 'autoDelete='

 

For the above error , can you please add below statement in sdc.properties file 

 

http.server.additional.mime.types=text/csv and restart the collector and check if it helps

 

Thanks & Regards

Bikram_

Reply