30 Days PostmanDeveloper : Day 25

I am stuck at several points:

1-I don’t know how to put randomInt in the request

const colorAPIRequest = {
// url: http://thecolorapi.com/id?rgb=rgb($[$randomInt}, $ {$ randomInt}, $ {$ randomInt}),
url: http://thecolorapi.com/id?rgb=rgb(1, 2, 999),
method: ‘GET’
};

2-I don’t understand how to use the replaceIn

var body =
{
“hex”: “{{$ randomHexColor}}”,
“rgb”: “rgb ({{$ randomInt}}, {{$ randomInt}}, {{$ randomInt}})”,
“name”: “{{rgbName}}”,
}
;

 body = pm.variables.replaceIn (body, rgbName);
 pm.collectionVariables.set ('payload', JSON.stringify (body));

Please help

1 Like

@jomenor Welcome to the Community :partying_face:

  1. I can give a hint here, please check what are the mandatory params for the color API in the documentation :blush: Not all the fields are required.

  2. For Dynamic variables, please refer this page.

You can use replaceIn() method like below:

Now you assign this to a variable (for example hex) and that can be accessed like

http://thecolorapi.com/id?hex=${hex}
1 Like

@bpricilla thanks for the help!

I will try again today :slight_smile:

1 Like