You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JMeter调用API已传入所有必填字段仍返回400响应码求助

Hey there, let's figure out why you're hitting that 400 Bad Request when calling the Snapmed contact API at https://snapmed.no/kontakt-1. A 400 error usually means the server can't make sense of your request, so here are the most likely issues and how to fix them:

Common Causes & Fixes for the 400 Response
  • Missing mandatory form fields
    Contact forms almost always require more than just a CSRF token and redirect URL. Chances are you're skipping required fields like name, email, message, or a phone number that the server expects. Head over to the actual Snapmed contact page, right-click and inspect the form to list every <input> with a name attribute—all of these need to be included in your request body.

  • CSRF token validation failure
    Even though you're sending craft_csrf_token, make sure:

    • You grabbed the token correctly from the site's cookies or the form's hidden input (stale or incorrect tokens will get rejected by Craft CMS).
    • The parameter name matches exactly what the server expects—double-check if it's really craft_csrf_token (some setups use _csrf instead).
  • Wrong request method
    Confirm you're using the POST method for this endpoint. Contact forms never accept GET requests, so if you're accidentally using GET, that's a sure way to get a 400.

  • Incorrect request headers
    Servers often check headers like Content-Type to ensure your request body is formatted right. If you're sending form data, set Content-Type: application/x-www-form-urlencoded (for key-value pairs) or multipart/form-data (if there are file uploads). If you're using JSON, make sure the header is application/json and your body is valid JSON.

  • Invalid redirect parameter
    The redirect value needs to be a URL the server recognizes (either relative to the site or a valid absolute URL). If you're using an invalid or unauthorized URL here, the server might reject the request. Try using the same redirect value that the original form uses (check the form's hidden inputs or action attribute).

Quick Debugging Tips
  1. Inspect the live form
    Visit the Snapmed contact page, right-click > Inspect Element, then look at the <form> tag and all its child inputs. Note every name attribute—these are the exact parameters you need to send.
  2. Capture a working request
    Use your browser's DevTools (Network tab) to submit the form manually. Copy the headers, form data, and CSRF token from that successful request to replicate it in your code.
  3. Double-check your request body
    Make sure all required fields are present, values are in the correct format (like a valid email address), and there are no typos in parameter names.

内容的提问来源于stack exchange,提问作者pragneshReddy Nandyala

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 20:02:36