Hello everyone :wave: I have just signed up for a ...
# pactflow
j
Hello everyone 👋 I have just signed up for a demo pactflow account. I am quite keen to see how the automatic stub generation works. I am trying to access the stub that is generated for the example integration
A pact between Example App and Example API
that has been given. I am making a request to
Copy code
curl --location --request GET 'https://{myDomain}.<http://pactflow.io/pacts/provider/Example|pactflow.io/pacts/provider/Example> API/consumer/Example App/latest/stub/alligators/Mary' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {token}'
But I am getting a 400 Bad Request back, what am I doing wrong?
👋 1
y
Hi James, thanks for signing up, I don't mind having a look with you. Did you copy the stub url from an option in the Pactflow ui?
Your curl snippet looks ok, although I'd normally encode the spaces in the url, and not sure if you need the
/alligators/mary
I've just tried it against mine to retrieve a pact and it worked fine
Copy code
curl --location --request GET '<https://you54f.pactflow.io/pacts/provider/example%20provider/consumer/example%20consumer/version/LOCAL_DEV>' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer xyz'
Will test it with the
/stub/
endpoint and let you know
j
Hey @Yousaf Nabi (pactflow.io) I built the URL from this blog post https://pactflow.io/blog/hosted-stubs/
y
Great thanks for that, I've just got it working, using the detail from the latest docs here
Copy code
curl -v --location --request GET '<https://you54f.pactflow.io/pacts/provider/example%20provider/consumer/example%20consumer/latest/stub/dogs>' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer xyz'
Let me go through the post above and run through it 🙂
Can you fire me a copy of the pact file you are testing against please?
j
yeah sure
Copy code
{
  "consumer": {
    "name": "Example App"
  },
  "provider": {
    "name": "Example API"
  },
  "interactions": [
    {
      "_id": "ef69ceef4d7fb82af014da950a3d9028a905c4de",
      "description": "a request for an alligator",
      "providerState": "there is an alligator named Mary",
      "request": {
        "method": "get",
        "path": "/alligators/Mary",
        "headers": {
          "Accept": "application/json"
        }
      },
      "response": {
        "status": 200,
        "headers": {
          "Content-Type": "application/json;charset=utf-8"
        },
        "body": {
          "name": "Mary"
        },
        "matchingRules": {
          "$.body.name": {
            "match": "type"
          }
        }
      }
    },
    {
      "_id": "4b3c23c364f420e1d1296d56a47695de0428d0af",
      "description": "a request for an alligator",
      "providerState": "there is not an alligator named Mary",
      "request": {
        "method": "get",
        "path": "/alligators/Mary",
        "headers": {
          "Accept": "application/json"
        }
      },
      "response": {
        "status": 404,
        "headers": {}
      }
    },
    {
      "_id": "e57e7ac251a8bd078fcb81cad1e577cbafebcef5",
      "description": "a request for an alligator",
      "providerState": "an error occurs retrieving an alligator",
      "request": {
        "method": "get",
        "path": "/alligators/Mary",
        "headers": {
          "Accept": "application/json"
        }
      },
      "response": {
        "status": 500,
        "headers": {
          "Content-Type": "application/json;charset=utf-8"
        },
        "body": {
          "error": "Argh!!!"
        }
      }
    }
  ],
  "metadata": {
    "pactSpecification": {
      "version": "2.0.0"
    }
  },
  "createdAt": "2022-03-01T21:09:21+00:00"
}
b
@James Troughton if you're still stuck on this, send us an email to support@pactflow.io and we can have a look at the logs.
a
Hi @Beth (pactflow.io/Pact Broker/pact-ruby), is possible to inject behavior in these hosted stubs? i.g. in same cases is I need that some stubs have different behaviors depending on the input parameters or the data exchange between services or even to keep state between endpoints. I know that pactflow doesn't necessarily have that scope. However, I saw this post about hosted stubs and was thinking about this possibility.