openapi-to-postman icon indicating copy to clipboard operation
openapi-to-postman copied to clipboard

Unable to PUT collection with API, Lost basic auth credentials when import with application

Open kool79 opened this issue 3 years ago • 2 comments

When I try to import with API:

curl --location --request PUT "https://api.getpostman.com/collections/${collectionId}" \
--header 'X-Api-Key: PMAK-614b43d3xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data @collection.json 

then I get an error (see below).

{ "error": { "name": "malformedRequestError",  "message": "Found 120 errors with the supplied collection.",
    "details": [
      "item/2: must have required property 'request'",
      "item/2/item/0: must have required property 'request'",
      "item/2/item/0/item/0: must have required property 'request'",
      "item/2/item/0/item/0/item/8/request/auth: must be null",
      "item/2/item/0/item/0/item/8/request/auth/basic: must be array",                          <<<-------- ????
      "item/2/item/0/item/0/item/8/request/auth: must match exactly one schema in oneOf",
      "item/2/item/0/item/0/item/8/request: must be string",
      "item/2/item/0/item/0/item/8/request: must match exactly one schema in oneOf",
      "item/2/item/0/item/0/item/8: must have required property 'item'",
      "item/2/item/0/item/0/item/8: must match a schema in anyOf",
      "item/2/item/0/item/0: must match a schema in anyOf",
....

Error is truncated but all other messages are similar to provided fragment. It seems that there are some issues with validation of basic auth format.

Notes: item/2/item/0/item/0 are folder items while item/8 is the request item. Corresponding part of imported collection is shown on screenshot. (Sorry, cannot share whole collection because it contains sensitive data) scr_2022_10_03T15_01_49

When I import the same collection with postman app I dont have any errors and collection imported succesfully. BUT (see screenshots) I lost credentials for basic auth in some requests. scr_2022_10_03T14_58_59

kool79 avatar Oct 03 '22 12:10 kool79

@kool79 Looks like the payload is collection v2 format while the API is expecting v2.1. Can you try updating the basic key with the following value:

[
  {
	  "key": "password",
	  "value": "test",
	  "type": "string"
  },
  {
	  "key": "username",
	  "value": "test",
	  "type": "string"
  }
]

For more info about the collection schemas, you can refer to this: https://schema.postman.com/

shubhbhargav avatar Oct 03 '22 18:10 shubhbhargav

@shubhbhargav Thanks, for help. Seems it is our issue when we merge collections in manual way (as jsons): in header we have v2.1 but below there is a v2.0 format. Current issue can be closed.

kool79 avatar Oct 04 '22 03:10 kool79

Closing the issue as suggested!

VShingala avatar Nov 22 '22 14:11 VShingala