How to test an API with query string from postman(or SOAP UI/Fiddler) [closed]

笑着哭i 提交于 2019-12-13 07:09:33

问题


I have an api link as following

https://hostaddress.com/api/v1/query

The API currently supports one endpoint: query. The query endpoint allows the user to make queries.

The query endpoint must be accessed with the GET HTTP method.

Requests to the query endpoint must be sent with the GET HTTP method. The required query parameter defines the query to be executed.It is a JSON object that is URL-encoded and passed as a parameter to the request.

URL encodes the query object and passes it as a query parameter.

For example, the following query object:

{
 "dataset": "my_data",
 "view": "time",
 "start": 1458250809000,
 "end": 1458250810000,
 "timezone_offset": -25200000,
 "measure": {
   "aggregator": "unique_count",
   "column": "impression"
 },
 "filter": "`action.event` = \"appDownloadLink\"",
 "sampled": true,
 "group_by": ["browser_type"],
 "max_groups": 10,
 "compute_all_others": false
}

would be URL encoded and passed as the following query parameter: https://hostaddress.com/api/v1/query?query=%7B%22dataset%22%3A%20%E2%80%9Cmy_data%E2%80%9D%2C%20%22start%22%3A%201458250809000%2C%20%22end%22%3A%201458250810000%2C%20%22timezone_offset%22%3A%20-25200000%2C%20%22view%22%3A%20%E2%80%9Ctime%E2%80%9D%2C%20%22measure%22%3A%20%7B%22aggregator%22%3A%20%E2%80%9Cunique_count%E2%80%9D%2C%20%22column%22%3A%20%E2%80%9Cimpression%E2%80%9D%7D%2C%20%22filter%22%3A%20%E2%80%9C%60action.event%60%20%3D%20%5C%22appDownloadLink%5C%22%E2%80%9D%2C%20%22sampled%22%3A%20true%2C%20%22group_by%22%3A%20%5B%E2%80%9Cbrowser_type%E2%80%9D%5D%2C%20%22max_groups%22%3A%2010%2C%20%22compute_all_others%22%3A%20false%7D

How do i test for the response from POSTMAN by passing the query object as querystring?


回答1:


Seems trivial but just use Postman and do a GET to the URL you provided:

https://hostaddress.com/api/v1/query?query=%7B%22dataset%22%3A%20%E2%80%9Cmy_data%E2%80%9D%2C%20%22start%22%3A%201458250809000%2C%20%22end%22%3A%201458250810000%2C%20%22timezone_offset%22%3A%20-25200000%2C%20%22view%22%3A%20%E2%80%9Ctime%E2%80%9D%2C%20%22measure%22%3A%20%7B%22aggregator%22%3A%20%E2%80%9Cunique_count%E2%80%9D%2C%20%22column%22%3A%20%E2%80%9Cimpression%E2%80%9D%7D%2C%20%22filter%22%3A%20%E2%80%9C%60action.event%60%20%3D%20%5C%22appDownloadLink%5C%22%E2%80%9D%2C%20%22sampled%22%3A%20true%2C%20%22group_by%22%3A%20%5B%E2%80%9Cbrowser_type%E2%80%9D%5D%2C%20%22max_groups%22%3A%2010%2C%20%22compute_all_others%22%3A%20false%7D



回答2:


For anyone who stumbled here google searching a solution, you can include nested query parameters in postman using brackets, like in the following example (using the object mentioned by the OP):

https://hostaddress.com/api/v1/query?dataset=my_data&measure[aggregator]=unique_count&measure[column]=impression&compute_all_others=false


来源:https://stackoverflow.com/questions/38340955/how-to-test-an-api-with-query-string-from-postmanor-soap-ui-fiddler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!