Malformed variable URL when using with Monitor

Hey, I have working tests when running via Collection Runner but when I created Monitor for my TestSet where URL and other parameters are set as global variables it gets malformed…

When I run the code with variables in the Monitor

There is an error:

but when I try to run the code without any variables

hard-coded to the URL it passes the test

Any idea how to fix it?

Thank you!

I don’t believe that the monitor would know what those global parameters are, have you tried these in a different scope?

I haven’t …

Here is the full console output:
19:40:48Preparing run.
19:40:48Running…Hide run logs
Line Number Timestamp Console Output
1 19:40:48 Open Weather - Monitor started
2 19:40:48 Status 200
3 19:40:48 GET
4 19:40:48 Response Time Is Less Than Limit
5 19:40:48 GET {{openWeatherURL}}?q=prague&appid={{openWeatherAPIKey}}
6 19:40:48 Error: Invalid URI “http:///%7B%7BopenWeatherURL%7D%7D?q=prague&appid=%7B%7BopenWeatherAPIKey%7D%7D”
7 19:40:48 Failed: Response time is less than limit
8 19:40:48 Response time was longer than 100 ms.: expected undefined to be a number or a date
9 19:40:48 Object Value Types
10 19:40:48 GET {{openWeatherURL}}?q=prague&appid={{openWeatherAPIKey}}
11 19:40:48 JSONError: Unexpected token u in JSON at position 0
12 19:40:48 JSONError: Unexpected token u in JSON at position 0
13 19:40:48 Object Values
14 19:40:48 GET {{openWeatherURL}}?q=&appid={{openWeatherAPIKey}}
15 19:40:48 Form param file, file load error: file resolver not supported
16 19:40:48 Error: Invalid URI “http:///%7B%7BopenWeatherURL%7D%7D?q=&appid=%7B%7BopenWeatherAPIKey%7D%7D”
17 19:40:48 Failed: Response has set correct data value
18 19:40:48 Unexpected token u in JSON at position 0
19 19:40:48 Open Weather - Monitor finished
19:40:48Run failed.

It also gets malformed when I right-click in Postman to {{openWeatherURL}} variable and click to EncodeURIComponent… Any idea of how to change encoding settings for that Component? :slight_smile:

If you have these as global variables the monitor won’t know what these are and won’t know what to resolve those values as.

You need to either place them in the Collection as CollectionVariables or add them to an environment and select that when you create the monitor.

1 Like

Thank you once again! All working now!

1 Like