# 400 Bad request

**URL:** <https://community.postman.com/t/400-bad-request/18252>\
**Category:** Help Hub\
**Created:** [December 4, 2020, 6:55pm UTC](https://community.postman.com/t/400-bad-request/18252 "2020-12-04T18:55:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshuacos1977](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@joshuacos1977](https://community.postman.com/u/joshuacos1977)\
**Post date:** [December 4, 2020, 6:55pm UTC](https://community.postman.com/t/400-bad-request/18252/1 "2020-12-04T18:55:12Z")

</div>

**Your question may already have an answer on the community forum. Please search for related topics, and then read through the [guidelines](https://community.postman.com/t/about-the-just-getting-started-category/37) before creating a new topic.**

I try to test GET and POST request on FlexSearch Server which eventually I have to create a search index on my web portal.  
So I want to see if the server’s response both POST and GET,however,I get “400 Bad request” error every time.Moreover the error point out that “The request cannot be fulfilled due to bad syntax”.

The GET and POST requests are below:

The GET:

```auto
http://localhost:9800/indices/contact HTTP/1.1

```

THE POST

```auto
http://localhost:9800/indices HTTP/1.1

```

and body for the post:

```auto
Content-Type: application/json; charset=utf-8

{
  "indexName": "contact",
  "fields": [
    {
      "fieldName": "employeeid",
      "fieldType": "Keyword",
    },
    {
      "fieldName": "firstname"
    },
    {
      "fieldName": "lastname",
    },
    {
      "fieldName": "dob",
      "fieldType": "DateTime",
    }
  ]
}

```

Where do I make a mistake?  
I would be appreciated to your response.

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [December 5, 2020, 2:51am UTC](https://community.postman.com/t/400-bad-request/18252/2 "2020-12-05T02:51:30Z")

</div>

@joshuacos1977 Warm welcome to this Community 🙂

Just by quick eye-balling I see that JSON format is incorrect. Removed the trailing commas to fieldType.

```auto
{
   "indexName":"contact",
   "fields":[
      {
         "fieldName":"employeeid",
         "fieldType":"Keyword"
      },
      {
         "fieldName":"firstname"
      },
      {
         "fieldName":"lastname"
      },
      {
         "fieldName":"dob",
         "fieldType":"DateTime"
      }
   ]
}

```

Can you please try with this JSON?

Usually bad request happens when there is some error is your body which couldn’t be handled by your API, or some syntax error in the body 🙂

---

<div class="post-metadata">

**Author:** ![joshuacos1977](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@joshuacos1977](https://community.postman.com/u/joshuacos1977)\
**Post date:** [December 5, 2020, 6:54pm UTC](https://community.postman.com/t/400-bad-request/18252/3 "2020-12-05T18:54:45Z")

</div>

> [@joshuacos1977](#):
>
> `Content-Type: application/json; charset=utf-8`

I am still getting the same error.  
Should I put “Content-Type: application/json; charset=utf-8” on my body or address?

---

<div class="post-metadata">

**Author:** ![joshuacos1977](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@joshuacos1977](https://community.postman.com/u/joshuacos1977)\
**Post date:** [December 5, 2020, 6:59pm UTC](https://community.postman.com/t/400-bad-request/18252/4 "2020-12-05T18:59:51Z")

</div>

> [@bpricilla](#):
>
> ```auto
> {
> "indexName":"contact",
> "fields":[
> {
> "fieldName":"employeeid",
> "fieldType":"Keyword"
> },
> {
> "fieldName":"firstname"
> },
> {
> "fieldName":"lastname"
> },
> {
> "fieldName":"dob",
> "fieldType":"DateTime"
> }
> ]
> }
> 
> ```

is my request correct format ?I mean  
[http://localhost:9800/indices](http://localhost:9800/indices) HTTP/1.1

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [December 6, 2020, 2:39am UTC](https://community.postman.com/t/400-bad-request/18252/5 "2020-12-06T02:39:08Z")

</div>

@joshuacos1977 Your content type should be as part of Headers section like below:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/b/7/b7d79e8e1af8b3c771ff845a70b271b6fb49fb61.png)

Also how are you passing the body section? As RAW JSON? Like this?

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/2/9/2948445822b9154c5742d1749f77ad122d9ef324.png)

Can you please provide me more details/screenshots to say exactly what’s not working 🙂?

---

<div class="post-metadata">

**Author:** ![allenheltondev](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/allenheltondev/32/31738_2.png) [@allenheltondev](https://community.postman.com/u/allenheltondev)\
**Post date:** [December 7, 2020, 12:34pm UTC](https://community.postman.com/t/400-bad-request/18252/6 "2020-12-07T12:34:24Z")

</div>

What is the message being returned? 400 typically means you passed something invalid to the API. These error messages tend to be pretty helpful when it comes to figuring out what is wrong.

---

<div class="post-metadata">

**Author:** ![haviernick](https://avatars.discourse-cdn.com/v4/letter/h/91b2a8/32.png) [@haviernick](https://community.postman.com/u/haviernick)\
**Post date:** [March 16, 2021, 5:52am UTC](https://community.postman.com/t/400-bad-request/18252/7 "2021-03-16T05:52:29Z")

</div>

> [@joshuacos1977](#):
>
> “400 Bad request” error

The 400 (Bad Request) status code indicates that the server cannot or will not process the request because the received syntax is invalid, nonsensical, or exceeds some limitation on what the server is willing to process. It means that the request itself has somehow incorrect or corrupted and the server couldn’t understand it. The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method . Therefore, it prevents the website from being properly displayed. The main thing to understand is that the [400 Bad Request](http://net-informations.com/q/mis/400.html) error is a client-side error. The cause of a 400 error can be a wrongly written URL or a URL that contains unrecognizable characters. Another cause of the error might be an invalid or expired cookie. Also, if you try to upload a file that’s too large. If the server is programmed with a file size limit, then you might encounter a 400 error.

---

<div class="post-metadata">

**Author:** ![supply-administrator](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@supply-administrator](https://community.postman.com/u/supply-administrator)\
**Post date:** [July 13, 2023, 11:00am UTC](https://community.postman.com/t/400-bad-request/18252/8 "2023-07-13T11:00:06Z")

</div>

Have the same issue with the client (windows). Same profiles are working from Postman online without any problems. When using the windows client, Postman respond is “HTTP Error 400. The request hostname is invalid.”

```auto
<HEAD>
	<TITLE>Bad Request</TITLE>
	<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii">
</HEAD>

<BODY>
	<h2>Bad Request - Invalid Hostname</h2>
	<hr>
	<p>HTTP Error 400. The request hostname is invalid.</p>
</BODY>

</HTML>

```
