Having issue with last part on skill check of check progress part in Student expert collection.
ânameâ: âAdded a scriptâ,
âhintâ: âAdd a test script that gets the value of the rand property in the response JSON and sets itas the value of a variable (at collection or environment scope) named responseData. Hint: Youâll need to Send the request twice after adding your code because it wonât save the value until after the response is received the first time.â,
âvalueâ: false
}
],
ârandâ: âJuanaâ
My code in test script was:
pm.test(âStatus code is 200â, function() {
pm.response.to.have.status(200);
});
pm.test(âStats include all fieldsâ, function() {
var jsonData = pm.response.json().rand;
pm.environment.set(âjsonDataâ, jsonData);
});
We canât provide the answer because the purpose of this part of the template is for you to learn how to reapply what you learned in the first sections. If you look back at the requests in the second folder youâll see examples that are similar to what you need here.
I have the same problem, I have already added the test and a console.log to check if the answer is being recorded in the environment variable.
I donât want you to give me the answer, I would like to know if mine is wrong, in my opinion there is something wrong with the exercise verification var jsonData = JSON.parse(responseBody); pm.test('verifica retorno da variavel', function () { pm.environment.set("responseData", jsonData.rand); pm.expect(jsonData.rand).to.eql("Kamron") console.log(jsonData.rand) })
I am delighted with all the features of the postman congratulations to the whole team.
Hi @ferpioli, the part of your code that is setting the var looks correct, if youâre seeing a test fail I believe thatâs probably due to the test you have set to check the hard-coded string (the rand field will change between sessions)âthe request does not require this to be built into a test, it just requires you to set the var.
Hi, @suesmith even without this test, Iâm still taking the error, what can be happening?
var jsonData = JSON.parse(responseBody);
pm.test(âverifica retorno da variavelâ, function () {
pm.environment.set(âresponseDataâ, jsonData.rand);
console.log(jsonData.rand)
})
@suesmith Thanks for somewhat looking back. After reading responses in this question and looking back at previous ones, found that I was missing the console.log statement, so nothing was ever being returned
Hmm your code works when I try itâyou are hitting the send button twice (you need to because the var is set after the request sends)? Can you also open the environment to check what the var value is for me?
@suesmith Is that link we are to use in the student expert portion? just want to make sure I am using the right link. thatâs what steps I was following but was unclear if it was right
That is the link to submit your collection to receive the badge if Iâm understanding your question correctly. However if there is an issue with the link we will follow up with you!
@suesmith
Once I share the link, and run the test collection one. I get these tests failing. But the skills pass. not sure what to do
Used GET, POST, PUT, DELETE methods | AssertionError: expected [ âGETâ, âGETâ ] to be a superset of [ âGETâ, âPOSTâ, âPUTâ, âDELETEâ ]
FAIL
Used query and path parameters | AssertionError: expected to have a length above 0 but got 0
FAIL
Sent body data | AssertionError: expected to have a length above 0 but got 0
FAIL
Used variables | AssertionError: expected to have a length above 0 but got 0
FAIL
Added request description | AssertionError: expected to have a length above 0 but got 0
Hi @ferpioli I believe I can see the issue, you seem to have removed a header from the request which is required for this to workâif you can import the student expert template over again and open the skill check request you should see there is meant to be one in there named response-value that has gone missing from yours. Feel free to copy it from the newly imported version into your completed collection and try again.
@anantsan the collection is missing some required partsâmaybe you havenât saved your requests from the first two foldersâŚ? When you work through the steps in the first two folders you need to make sure your requests are saved, and update the share link before trying again.