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

Withmultipart_formdata is not accepting json payload #380

Open
JyotiPMallick opened this issue Sep 14, 2024 · 5 comments
Open

Withmultipart_formdata is not accepting json payload #380

JyotiPMallick opened this issue Sep 14, 2024 · 5 comments

Comments

@JyotiPMallick
Copy link

JyotiPMallick commented Sep 14, 2024

Describe the bug

I am trying to make a post call with accept multipart form data, and one of its parameters (this one is mandatory) is only accepting JSON payload. But the spec handler is unable to identify the JSON data.

To Reproduce
Steps to reproduce the behavior:

My spec handler :

image

My JSON payload which contains some synthetic data produced through function,

image

Now while running I am getting the below error,

image

Same thing from the browser

image

Expected behavior
It should add the details.

Software (please complete the following information):

  • OS: [Windows]
  • NodeJS Version [ 14]
  • Test Runner [e.g mocha]

Any clue what I am missing here ?

@ASaiAnudeep
Copy link
Member

Hello @JyotiPMallick , is the RegisterCompany is a data template?

If so, we need to use @DATA:TEMPLATE@. For example:

spec.withMultiPartFormData({ '@DATA:TEMPLATE@': 'RegisterCompany' })

@JyotiPMallick
Copy link
Author

You mean something like spec.withMultiPartFormData({ companyDto: {"@DATA:TEMPLATE@": "RegisterCompany" }}); ?

@JyotiPMallick
Copy link
Author

JyotiPMallick commented Sep 17, 2024

addSpecHandler("Register a new company", ({ spec }) => {
  spec.post(paths.COMPANY_REGISTRATION);
  spec.withMultiPartFormData({ companyDto: {"@DATA:TEMPLATE@": "RegisterCompany" }});
  spec.expectStatus(200);
});

I am getting TypeError: source.on is not a function error.

@ASaiAnudeep
Copy link
Member

Can you please share the stack trace of the error.

@JyotiPMallick
Copy link
Author

  Registering a new company should return expected http status code 200 proper data in the response time.:
     TypeError: source.on is not a function
      at DelayedStream.create (node_modules\delayed-stream\lib\delayed_stream.js:33:10)
      at CombinedStream.append (node_modules\combined-stream\lib\combined_stream.js:45:37)
      at FormData.append (node_modules\form-data-lite\src\index.js:75:3)
      at setMultiPartFormData (node_modules\pactum\src\helpers\requestProcessor.js:134:34)
      at Object.process (node_modules\pactum\src\helpers\requestProcessor.js:22:5)
      at Tosser.toss (node_modules\pactum\src\models\Tosser.js:32:39)
      at Spec.toss (node_modules\pactum\src\models\Spec.js:540:19)
      at Spec.then (node_modules\pactum\src\models\Spec.js:544:10)

Here it is

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

2 participants