简体   繁体   中英

How to pass parameters in HTTP POST request?

I created an API KEY using thingSpeak of the page http://www.latlong.net/Show-Latitude-Longitude.html . The page takes two inputs latitude and longitude and provides the location name as the output.

https://api.thingspeak.com/apps/thinghttp/send_request?api_key=OQHAGOXG1YOYJPZC this is the equivalent address to the web page using the API_KEY.In this I want to pass the inputs (Latitude and Longitude) too.How can I do that.(ie I want to obtain a link which when executed will give me the page showing the output).

How can i pass the parameters latitude and longitude to this page through the above equivalent address.

you can use a program like Postman to manually send requests to that endpoint, and you can populate the body too. Using jquery, this is how you would send a POST to that endpoint:

var endpoint = https://api.thingspeak.com/apps/thinghttp/send_request?api_key=OQHAGOXG1YOYJPZC;
var data = new Object();
data.longitude = 50;
data.latitude = 50;
$.ajax({
            type: 'POST',
            data: data,
            url: endpoint,
            contentType: 'application/json; charset=utf-8',
            success: function (response) {

            },
            error: function (response) {

            }
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM