So i am working a bit with GET and POST requests right now, and have been trying to understand the format that my data is being sent out as.
In the documentation you can see the parameters are as follows:
Parameters
url_
HTTP(S) URL to read, as UTF-8
data_
Dictionary of data to be JSON-encoded and sent to url_; root-level members of the dictionary will be used as individual POST arguments, and the member values will be individually JSON-encoded as POST argument values
success_
Callback to perform when the request completes successfully
failure_
Callback to perform when the request fails
I understand everything about this so far, minus the data_ param, which is slightly confusing (or i am just a noob). I am structuring my data using nlohman::json library to create my inital json data, then i store it inside of a dictionary pref for the ::InternetPOST type.
It accepts it and i get an error back from the server i am pinging which definitely means that the data is going through, but i cannot seem to understand the format that the data is being sent out as.
From reading the docs it seems like if i give it the following json ():
{
"application": {
"name": "my_application",
"version": 0.0.1,
"os": "MACOS"
}
};
Then i use the following to format it and pass it into my hdi::core::InternetPost request:
**.dump() comes from the nlohman::json library and returns a string representation of the json data.
std::unique_ptr<hdi::core::PrefData> _dict = hdi::core::DictionaryPref::parse(data.dump());
this->__connectToPOST = hdi::core::InternetPOST::Async("http://localhost:9999/connect", *dynamic_cast<hdi::core::DictionaryPref*>(_dict.get()), HDI_CORE_CALLBACK(Plugin, this, successfulPost), HDI_CORE_CALLBACK(Plugin, this, unsuccessfulPost));
So if that is the case - i am just curious if anyone knows how the data goes out and is made in the request.
What i understand is it comes back as "application/$stringshereasparameters?";
Let me know if anyone can help!!
In the documentation you can see the parameters are as follows:
Parameters
url_
HTTP(S) URL to read, as UTF-8
data_
Dictionary of data to be JSON-encoded and sent to url_; root-level members of the dictionary will be used as individual POST arguments, and the member values will be individually JSON-encoded as POST argument values
success_
Callback to perform when the request completes successfully
failure_
Callback to perform when the request fails
I understand everything about this so far, minus the data_ param, which is slightly confusing (or i am just a noob). I am structuring my data using nlohman::json library to create my inital json data, then i store it inside of a dictionary pref for the ::InternetPOST type.
It accepts it and i get an error back from the server i am pinging which definitely means that the data is going through, but i cannot seem to understand the format that the data is being sent out as.
From reading the docs it seems like if i give it the following json ():
{
"application": {
"name": "my_application",
"version": 0.0.1,
"os": "MACOS"
}
};
Then i use the following to format it and pass it into my hdi::core::InternetPost request:
**.dump() comes from the nlohman::json library and returns a string representation of the json data.
std::unique_ptr<hdi::core::PrefData> _dict = hdi::core::DictionaryPref::parse(data.dump());
this->__connectToPOST = hdi::core::InternetPOST::Async("http://localhost:9999/connect", *dynamic_cast<hdi::core::DictionaryPref*>(_dict.get()), HDI_CORE_CALLBACK(Plugin, this, successfulPost), HDI_CORE_CALLBACK(Plugin, this, unsuccessfulPost));
So if that is the case - i am just curious if anyone knows how the data goes out and is made in the request.
What i understand is it comes back as "application/$stringshereasparameters?";
Let me know if anyone can help!!