Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when collection is converted to json, query property have weird schema #1344

Open
mfaizan1 opened this issue Dec 4, 2023 · 0 comments
Open

Comments

@mfaizan1
Copy link

mfaizan1 commented Dec 4, 2023

I have tried 2 ways to do this both resulted in same

Directly manipulating url

    const request = new Request({
      header: requestHeader,
      url: `${apiEndpoint}?${new URLSearchParams(params).toString()}}`,
      method: 'GET',
      auth: null,
    });

using QueryParam

    Object.keys(params).forEach((key) => {
      const queryParams = new QueryParam({
        key,
        value: params[key],
      });
      request.addQueryParams(queryParams);
    });

both result into query property like this

"query": [
	{
		"key": "members",
		"value": {
			"prop1": {
				"key": "keyName",
				"value": "VALUE"
			},
			"prop2": {
				"key": "keyName2",
				"value": "VALUE2"
			},
		]
	},
	{
		"key": "reference",
		"value": {
			"prop1": {
				"key": "keyName",
				"value": "VALUE"
			},
			"prop2": {
				"key": "keyName2",
				"value": "VALUE2"
			},
		}
	},
	{
		"key": "Type",
		"value": {
			"_postman_propertyName": "QueryParam",
			"_postman_propertyIndexKey": "key",
			"_postman_propertyAllowsMultipleValues": true
		}
	},
	{
		"key": "_postman_listIndexKey",
		"value": "key"
	},
	{
		"key": "_postman_listAllowsMultipleValues",
		"value": true
	}
],

when this data is imported into postman it results in this url
{{url}}?members&reference&Type&_postman_listIndexKey=key&_postman_listAllowsMultipleValues

I cross checked by exporting postman collection and there query is array of objects

{
	"key": "KEY1",
	"value": "VALUE1"
},
{
	"key": "KEY2",
	"value": "VALUE2"
},

This happens when using collection.toJSON(), when request.toJSON() is used it in expected format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant