Day 25: Dynamic request bodies error code

My question: I am trying to get a json resonse from thecolorapi.com and I’m getting this error code in the console. I have disabled my adblocker.

Details (like screenshots):

Screen Shot 2021-10-18 at 8.28.09 PM

My code so far:"

let color_var = pm.variables.replaceIn('{{$randomHexColor}}');
let hex_var = color_var.slice(1);

console.log(hex_var);

pm.sendRequest("http://thecolorapi.com/id?hex=" + hex_var, function (err, response) {
    console.log(response.json());
});

Hi @pamelagilmour,
I have seen the same experience here when I tried to reproduce the error. But I ran it against https:// and the web app asked me if I want to disable SLL validation. After disabling the validation in the response window, I get this in the console, a 200 with a warning only:

image

Try running the request against https://thecolorapi.com first in a spearate tab. It will ask you to disable SSL validation. (Which in general is a bad idea, but for the sake of this challenge, let’s just do it.)

image

After that run your request once again and it should work. Hopefully. Let me know if not.

Hi @pamelagilmour ,

Now thecolorapi returns 404 page.

<html><body><b>Not Found 404.0</b></body></html>

1 Like

Hey @pamelagilmour !

Could you try prefixing ‘www.’ to you request URL? I’m getting appropriate response for the following request:

pm.sendRequest({
    url: 'http://www.thecolorapi.com/id?hex='+number,
    method: 'GET',

Good luck!

2 Likes

Hi @thatjan thank you for sharing, apologies for the late reply. I tried tinkering with the SLL validation and still couldn’t get a valid response. If I remember correctly, I stepped away for a few days and for some reason it worked. I got a response from the Color API. Somewhat unrelated, I also noticed somewhere along the way a ‘new line’ character was inserted into my Postman API Key in my Environment variables which also took a while to uncover. Anyway, thanks for responding.

Yeah @wirtaw, I think we were just calling the Color API on a bad day or something. Thank you for responding!!

This worked! Thank you @bbahadur !!!

1 Like

i have qs : why do you need “let hex_var = color_var.slice(1);”
i dont get this ?
Thanks advanced

when i delete it . I see everything is still successful?

I completed this almost a year ago, so I can’t say why I wrote that.

The administrators are always updating the challenges so it may have meant something a year ago. Or maybe I was testing stuff out and didn’t clean up my code when I was done as there are console.log()'s etc…

1 Like