Skip to content

POST request #35

@sharma1981

Description

@sharma1981

What is the way to modify the below sample to send a POST request?
By default performRequest makes a GET request as per the examples.

``#include <NFHTTP/NFHTTP.h>

#include
#include

#include <nlohmann/json.hpp>

using namespace std;

int main()
{

auto client = nativeformat::http::createClient(nativeformat::http::standardCacheLocation(),"NFHTTP-" + nativeformat::http::version());
const std::string url = "http://www.google.com";
auto request = nativeformat::http::createRequest(url, std::unordered_map<std::string, std::string>());
auto token = client->performRequest(request, [](const std::shared_ptrnativeformat::http::Response &response) {
size_t data_length = 0;
printf("Received Response: %s\n", response->data(data_length));
});
auto response = client->performRequestSynchronously(request);
size_t data_length = 0;
printf("Received Response: %s\n", response->data(data_length));

return 0;
}``

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions