Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to send URL as utf-8 encoded string in httpie post request

I have to do the following task:

Please create a public http or https service. It must have a
publicendpoint that accepts array of int32 numbers encoded as json in
the request body and returns result as a number. Once deployed, pass
the url of that endpoint to this service root in the request body as
utf8 encoded string. If successful you will get a success code to give
to us via upwork chat.

The URL I need to pass is: https://fast-api-test-app-f922f0fd9a50.herokuapp.com/

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

to this URL: http://194.182.164.40/ with X-auth (which I have but won’t post here).

I have tried the following using httpie:

http POST http://194.182.164.40/ x-auth:"....." url="https://fast-api-test-app-f922f0fd9a50.herokuapp.com/process"

but keep getting this error message:

parse "{\"url\": \"https://fast-api-test-app-f922f0fd9a50.herokuapp.com/process\"}": first path segment in URL cannot contain colon

How can I solve this?

>Solution :

Once deployed, pass the url of that endpoint to this service root in the request body as utf8 encoded string.

It says you’re supposed to post only the URL itself. Not wrap it in JSON, and it doesn’t say anything about calling the key "url" or anything like it. So I suppose https://... must be the only content of the request body.

In HTTPie, you can do that using the --raw argument:

% http -v --raw="https://fast-api-test-app-f922f0fd9a50.herokuapp.com/" 194.182.164.40
POST / HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 53
Content-Type: application/json
Host: 194.182.164.40
User-Agent: HTTPie/3.2.3

https://fast-api-test-app-f922f0fd9a50.herokuapp.com/
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading