-
-
Notifications
You must be signed in to change notification settings - Fork 0
Make a GET request to a Dataverse
To make a custom GET request to a Dataverse one needs to call the function method String GetInfoFromDataverse(String url);
In the following piece of code a GET request is made to request the lock state on a specific dataset id (unsigned long
):
Dataverse dataverse = new Dataverse();
String id="dataset id";
String url="/api/datasets/"+ id +"/locks";
String rawResponse = dataverse::GetInfoFromDataverse(url);
The function method returns a string with the `rawResponse` from the `dataverse` server.
Next rawResponse
can be digested into a JSON using the appropriate Json class library specific to the platform one is coding. On embedded firmware programming of smart devices, the ArduinoJson
library must be included in the project (#include <ArduinoJson.h>
). JSON serialization of the response string can be done like in the following piece of code
bool uploadStatusNotOK=true;
String rawResponse = GetInfoFromDataverse("/api/datasets/"+ datasetInfoJson["data"]["id"] +"/locks");
const size_t capacity =2*rawResponse.length() + JSON_ARRAY_SIZE(1) + 7*JSON_OBJECT_SIZE(1);
DynamicJsonDocument datasetLocksJson(capacity);
// Parse JSON object
DeserializationError error = deserializeJson(datasetLocksJson, rawResponse);
if (error) {
mserial.printStr("unable to retrive dataset lock status. Upload not possible. ERR: "+error.f_str());
//mserial.printStrln(rawResponse);
return;
}else{
String stat = datasetInfoJson["status"];
if(datasetInfoJson.containsKey("lockType")){
String locktype = datasetInfoJson["data"]["lockType"];
mserial.printStrln("There is a Lock on the dataset: "+ locktype);
mserial.printStrln("Upload of most recent data is not possible without removal of the lock.");
// Do unlocking
// ...
}else{
mserial.printStrln("The dataset is unlocked. Upload possible.");
uploadStatusNotOK=false;
}
}
}
More info about this particular library can be found at the ArduinoJson website here.
Dataverse API in another coding language
Goto dataverse.org for another coding language that best suits your coding style and needs. Currently, there are client libraries for Python, Javascript, R, Java, and Julia that can be used to develop against Dataverse Software APIs
https://guides.dataverse.org/en/5.12/api/client-libraries.html
The Official API Guide can be found here. The Dataverse Software APIs allow users to accomplish many tasks such as…
- creating datasets
- uploading files
- publishing datasets
- and much, much more
… all without using the Dataverse installation’s web interface. APIs open the door for integrations between the Dataverse Software and other software. For a list, see the Integrations section of the Admin Guide.
Contents:
- What is an API?
- Types of Dataverse Software API Users
- API Users Within a Single Dataverse Installation
- API Users Across the Dataverse Project
- How This Guide is Organized
Email us with software installation questions. Please note our response time is generally 24 business hours. Follow us on Twitter: @dataverseorg
Report issues and contribute to our code: Report bugs and add feature requests in GitHub Issues or use GitHub pull requests, if you have some code, scripts or documentation that you'd like to share. If you have a security issue to report, please email [email protected].
Ask a question or start a discussion: Great place to publicly share feedback, ideas, feature requests, and troubleshoot any issues is in the Dataverse Users Community.
Join #dataverse on chat.dataverse.org to chat with the Dataverse community in real time, or leave a message that will be logged at https://view.matrix.org/alias/%23dataverse:matrix.org
You can get in touch with me on my LinkedIn Profile:
You can also follow my GitHub Profile to stay updated about my latest projects:
The PCB Desgin Files i provide here for anyone to use are free. If you like this Smart Device or use it, please consider buying me a cup of coffee, a slice of pizza or a book to help me study, eat and think new PCB design files.
______________________________________________________________________________________________________________________________
Before proceeding to download any of AeonLabs software solutions for open-source development and/or PCB hardware electronics development make sure you are choosing the right license for your project. See AeonLabs Solutions for Open Hardware & Source Development for more information.