Sending POST from HTML - html

I have an API at
http://example.com/createclass
In order to create a database entry I need the URL to be
http://example.com/createclass/:classid/:classname/:someotherid
How do I manipulate the URL string from my html page (This page takes input from the user)?
I do not want to send the body as a JSON. I know how to do that by serializing the form data into JSON and then sending it. I want to send the POST request to the following URL format:
http://example.com/createclass/200/blah/ksjdf32ebr21

Related

Is it possible to send Json Data in the POST request body and an image as form-data

I have a POST request that has an image attached as form-data. I would like to send additional data as json in the request body. Is this possible?
Thanks!
Within a single Request call is not possible.
as you can only define one type of body.
One way you can do it is to stringify your json object and sent it as a string params in your form-data

How to fetch json response instead of html response from a get request?

Opening https://www.coinome.com/exchange/data.json in browser shows a json,but while trying to fetch response by making a GET request,the returned response is in html format.
How to get JSON response instead of html response?
that's because the first time you perform the request to that url, the server returns an html form to check whether youare human or not.
Then after you compile and submit the form a cookie is returned.
You have to save that cookie and redo the request to the same url while putting the cookie in the request header in order to get the response in json format.

Sample JSON request for multipart form

I want to call a rest API and my request body is composed in a json file. I want to send the request as multipart/form. Request body containst some text fields and several files for which I decide to use multipart form. I have found alot of logical example requests on internet but no concrete example in json format.
How would a sample json request body look like?
Finally found out that there is no such JSON representation of multipart/data requests. Infect thats just not possible using the json format. So multipart data request literally looks like the attached screenshot:

How do i get JSON data from a couchDB database and parse it in Xcode?

For Example,
I have a document in my CouchDB database that holds two fields
"password" and "username".
This is the URL for my document:http://127.0.0.1:5984/_utils/document.html?sgram/fdcfc14940fbaa0d86674046ce005107
I want to retrieve the value of these fields from that specific document in CouchDB and parse it in Xcode.
I tried using http-get but it just returns the entire page source.
You want to make a request to this endpoint
http://127.0.0.1:5984/sgram/fdcfc14940fbaa0d86674046ce005107
For a json response from couchdb just don't include _utils/document.html in between. If you do it will give you back the futon html page.

Consuming JSON with encoded url

I am trying to get response from Java system which will send response in the JSON data format.
For request , the HTTP Method is POST ,
Content Type is application/x-www-form-urlencoded and
Input params is
credentials=user10,TCS&password=TCS&action=getUserItem
s&domainName=user10&departmentId=
The url to connect the system is http://www.trex:5500/TCS/IntServelt
To connect the JAVA Restful services , below are my queries:
Should I form the url as
http://www.trex:5500/TCS/IntServelt&credentials=user10,TCS&password=TCS&action=getUserItems&domainName=user10&departmentId=
I have just copy pasted the Input parameter in the provided url ?
Does the sequence of the parameter matters? Is there any format for that?
Please share inputs.
Regards