Answer the question
In order to leave comments, you need to log in
Postman how to pass parameters correctly?
There is an API: https://api.nasa.gov
Using: Postman
Need to:
1. Find which cameras were used and how many pictures were taken by the Curiosity rover in sol 1666
2. Find a picture with id 268034 taken by the Opportunity rover with a panoramic camera on the first sol
Prompt How to correctly pass parameters to get the desired result?
In the 1st variant, everything seems to be clear, but I don’t know how to write the parameters to calculate the total number of shots, in sol 1666, they get enough sleep in a list with different id
Answer the question
In order to leave comments, you need to log in
Do you want the number returned directly in the query? I don't think there is such a thing. Can be counted as a script from Tests
https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?sol=1666&api_key=DEMO_KEY
const responseJson = pm.response.json();
var cameras = [];
responseJson["photos"].forEach(function (photo) {
var name = photo["camera"]["name"];
if (!cameras.includes(name)) {
cameras.push(name);
}
});
console.log("Total photos:", responseJson["photos"].length);
console.log("Cameras:", cameras);
https://api.nasa.gov/mars-photos/api/v1/manifests/Curiosity?api_key=DEMO_KEY
const responseJson = pm.response.json();
const sol = 1666;
responseJson["photo_manifest"]["photos"].forEach(function(photo) {
if (photo["sol"] == sol) {
console.log(photo);
return
}
})
Find a picture with id 268034 taken by the Opportunity rover with a panoramic camera on the first sol
const responseJson = pm.response.json();
const photoId = 268034;
responseJson["photos"].forEach(function(photo) {
if (photo["id"] == photoId) {
console.log(photo);
return
}
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question