1. OS: e.g. Mac OSX 10.12.6
  2. Consumer Pact library: e.g. Pact JS v5.5.0
  3. Node Version: 8.2.1

there is a post restful api with post body is plain text, when i use below code to generate a consumer pact file, it show JSON ParserError, seems the pact-js only support the json body, even i set the content-type as text/plain in the header

provider.setup()
    .then(() => {
      provider.addInteraction({
        state: 'I want to add a tag',
        uponReceiving: 'Step - 1 : add a tag',
        withRequest: {
          method: 'POST',
          path: "/api/v1/tags",
          headers: {
            "Content-Type": "text/plain;charset=UTF-8"
          },
          query: {
            "org": "testOrg"
          }
          body: "Tag_Pact_test_0001"
        },
        willRespondWith: {
          status: 200,
          body: {
              "result": 0
          }
        }
      })
    })

Is any way to send the text/plain body in post method?

0

There are 0 answers