Hi
For color api i have created random Hex color using the fake library and i stored it in the variable. On sending the get request it should get the appropriate name and rgb of that random hex color this is the prerequisite script i am not getting the response what i am excepting so in the prerequisite script itself i have embedded the get request to receive the name and rgb and it has to be the payload to the post method.
const setBg = () => {
const color = Math.floor(Math.random()*16777215).toString(16);
//console.log(color);
}
//var payload = JSON.stringify(body);
//pm.globals.set(βpayloadβ, payload);
//var color = d3.color(Math.floor(Math.random()*16777215).toString(16));
pm.sendRequest({
url: ' http://thecolorapi.com/id?hex={{color}}&rgb=0,71,171&hsl=215,100%,34%&cmyk=100,58,0,33',
method: 'GET',
header: 'headername1:value1',
body: {
rgb: " ",
name: " "
}
}, function (err, res) {
console.log(res);
});
and i am getting response as follow
βargsβ: {},
"data": {},
"files": {},
"form": {},
"headers": {
"x-forwarded-proto": "https",
"x-forwarded-port": "443",
"host": "postman-echo.com",
"x-amzn-trace-id": "Root=1-60ac0db5-053852865f7318ff028e2852",
"content-length": "0",
"authorization": "",
"user-agent": "PostmanRuntime/7.28.0",
"accept": "*/*",
"postman-token": "eac2df87-49f0-4006-9857-b709e18cf7bb",
"accept-encoding": "gzip, deflate, br",
"cookie": "sails.sid=s%3AMRNOeaMDE97Jh0s6gOVv_NU3p7169ijC.A1ERw8S3XNLN7mwbai2F7NscJpP%2BatrHUkTIN6JTIy8"
},
"json": null,
"url": "https://postman-echo.com/post"
what is wrong in my script thank you very much