Hello there, I keep having this test fail on the Galaxy API 101 training. I have done it over and over. I have checked my variables just to be sure I did not miss anything. Please can point me in the right direction on how to go about this.
Do you have that variable set at the environment level and in both the initial and current fields?
I’m not familiar with that collection as I didn’t write it but there is a comment in the test script, that mentions it can only check the environment level.
I have this training modules (and its still passing).
It doesn’t need to be environment variables. Mine are set at the collection level.
It looks like the test is failing on this element (not the line posted in the original screenshot).
//auth should also use var
pm.expect(encodeURI(authObj.apikey.value).indexOf('%7B%7B')).to.be.above(-1);
Suspect this is looking at the authentication which is set at the collection level and is using the email_key variable. (It should be set at the collection level, not the ‘Learn APIs’ folder level).
Have you already sorted it out, cause I’m also struggling with the same problem. Apparently, we are not using the variables correctly, but other than that the internet seems to not have a solution for the problem.
at folder level it is inherited from parent. i.e. (Galaxy APIs 101).
and if i removed it from folder level , then it also throws some more test to be failed. like saying auth error.
Leave the inherit from parent on the folder. It should be inherit from parent everywhere else apart from the collection.
I can only assume that you have this set somewhere else. You’ll need to check each request an folder and ensure they are all set to inherit from parent.
It currently has this: pm.expect(encodeURI(authObj.apikey.value).indexOf(‘%7B%7B’)).to.be.above(-1);
But authObj.apikey contains an array, not an object. It appears the intent of the test is to ensure that there are {{ contained in the value of apikey to indicate that a variable is used rather than a hardcoded value. I believe the test should instead be this:
I’ve still got this saved in my collections and although I loathe to say it, it works for me.
The indexOf() method returns the position of the first occurrence of a value in a string.
The indexOf() method returns -1 if the value is not found.
The indexOf() method is case sensitive
I still think that its because the candidates have the authentication set in more than one place, where it should be at the collection level and inherit from parent should be set everywhere else.
There should only be one apikey in the response and it should be set to {{email_key}}
It shouldn’t be returning more than one element. Therefore authObj.apikey.value should normally work.
%7B in an URL is converted to {
So the test is basically testing to see if the authObj.apikey.value contains {{