Search

Creating a ticket: Why a 400 Bad Request?

Subscribe to Creating a ticket: Why a 400 Bad Request? 3 post(s)

 
mtdowling

I’m trying to create a ticket using the API. Even though a summary and priority are being specified, I’m receiving a 400 Bad Request response stating that priority and summary must be set.

Request:
-——-

POST /api/v1/projects/1/tickets HTTP/1.1
Authorization: Basic XXX
User-Agent: XXX
Host: XXX.unfuddle.com
Accept-Encoding: deflate, gzip
Accept: application/xml
Content-Length: 179
Content-Type: application/x-www-form-urlencoded

<?xml version=“1.0”??>43Testing summaryThis is a test description

Response:
-———

HTTP/1.1 400 Bad Request
Date: Sun, 21 Feb 2010 21:52:31 GMT
Server: Apache
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 2.1.2
Cache-Control: no-cache
Set-Cookie: _unfuddle_session=XXX; domain=.unfuddle.com; path=/; expires=Sun, 21 Feb 2010 23:52:31 GMT; HttpOnly
Content-Length: 172
Status: 400
Vary: User-Agent
Connection: close
Content-Type: application/xml; charset=utf-8

<?xml version=“1.0” encoding=“UTF-8”??>Priority can only be one of the following: 5, 4, 3, 2, 1Summary can’t be blank

Any ideas why this error is occurring even though the things it’s complaining about are set in the request’s entity body?

 
Joshua Frappier

Thanks for providing such a detailed example. It was helpful in determining the source of your error.

You will notice that your request contains a header “Content-Type: application/x-www-form-urlencoded”. However, you are attempting to post XML. As such, your Content-Type header should rather be “application/xml”. If you change that you should find that the ticket creation happens without any problems.

 
mtdowling

Thanks for your assistance, Joshua. I guess I just overlooked the Content-Type header. I’ll give that a shot and post back if I have any problems. Thanks!

-Michael