0
  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?

  • resolved, use the text/plain in content-type should work, but just make sure the request and addInteraction same – Xiaoningz Mar 01 '18 at 04:23
  • please create an answer to your own question with what you did to fix it, then accept it :) – J_A_X Mar 07 '18 at 23:54

0 Answers0