...
Step | Screenshot | |||||
---|---|---|---|---|---|---|
Import Libraries (as needed)
After Python is up, import the requests {a library for doing any URL call}, sys, JSON, and time libraries into the virtual environment.
|
| |||||
Set the URL RequestSet the URL call to be an argument. Make a GET request against that URL. The response will need to set a default URL to call, if we don't have an argument. Set exceptions as 'e'. and The URL will be http://google.com. Our script returned a 200 status code. Our script will call either http://google.com or a URL that we provide. |
| |||||
Add JSON formatWhat JSON format does Apica’s back-end system expect? Apica’s back-end is based on MongoDB. MongoDB allows us to have an expandable result format. So that's a result format that you can upload almost anything to, and it will become a part of the result. We have the start and end times that we need. So the start and end times will be the start and end times of your check in ASM (These will show up in the check Result view in ASM).
Note: we're doing the Set a message. So our message is “URL call returned status code”, then adds a string response (the returned status code) the value that you see here, in the JSON format, it will be the value of the results. So this is the main value that you will see. Usually, it's the duration, but it could be anything. To show this, let's say that it's the status code, because this is what we're saying in the message. So we'll set it to |
| |||||
Expanding the Returned valuesLet's expand this a little bit; we have an expandable JSON format, so let's give ourselves more content and data. How many headers do we have here? What is the length of the returned content? Add these lines below the "value" (line 16 above) to return the response header count and the size of the content. |
|
...