Apis work if run 1 by 1 , but failed in Testing scenario

The custom script seen not working fine in testing scenario , failed to run in testing scenario

Get below error:
PostProcessor Script Error: “undefined” is not valid JSON

The error message is already clear: it occurs because the request to the API receives a redirect Location header from the server, and the request is being redirected more than 10 times, probably stuck in a redirect loop.

  1. If the individual steps work fine when tested separately but fail in the test case, based on the API URL related to the login shown in your screenshot. I suspect it may be related to how the server or the request in this particular test case handles cookies. You can compare the Actual Request when running the test scenario with the request when running the steps individually, and check if there are any inconsistencies in the headers or body.

  2. The PostProcessor-related error occurs because the scenario itself includes some post-processors that expect a JSON result, but the actual result does not match the expected JSON structure.