HTTP 409 Conflict on PUT, POST and DELETE requests

Imported Google Group message. Original thread at: Redirecting to Google Groups Import Date: 2016-01-19 21:10:29 +0000.
Sender:Marcelo.
Date:Sunday, 26 April 2015 00:28:19 UTC+1.

Hello everyone,

I’m getting error on every PUT, POST or DELETE requests. I’m using nginx as described in the documentation and I have all endpoints configured.

I’m getting “409 Conflict” with this body:

{
“error”: “Requested endpoint is forbidden”
}

Could anyone help me? Thanks in advance!

Imported Google Group message.
Sender:Martin Buhr.
Date:Monday, 27 April 2015 11:48:46 UTC+1.

Just a note, this is now fixed in our master branch and will be aprt of v1.6

  • show quoted text -

Imported Google Group message.
Sender:Marcelo.
Date:Sunday, 26 April 2015 08:38:44 UTC+1.

Hi,

Do you have any white listed paths enabled or mocking any replies? A white list would cause all requests except those that are specified to fail like this.

What is the output from Tyk, it will be outputting a warning.

Also, how is your key configured? Is it using access permissions, if so, what are they?

Thanks,
Martin

Imported Google Group message.
Sender:Martin Buhr.
Date:Sunday, 26 April 2015 12:09:41 UTC+1.

Hello Martin,

Thanks for reply. I have 4 APIs configured in Tyk. All APIs have paths configured and all are white listed. I have 1 mock response in each API. Tyk outputs nothing, it was my first try. Yes, I’m using keys, all my APIs are using Auth Token as Authentication mode and keys have right to access API.

Any tips? Thanks in advance!

Marcelo.

Imported Google Group message.
Sender:Marcelo.
Date:Sunday, 26 April 2015 12:28:50 UTC+1.

Hi,

Can you post a screenshot of one of the path definitions? I bet it’s misplaced slashes…

Thanks,
Martin

Imported Google Group message.
Sender:Martin Buhr.
Date:Sunday, 26 April 2015 14:16:19 UTC+1.

I hope so! Am I doing something wrong?

Imported Google Group message.
Sender:Marcelo.
Date:Sunday, 26 April 2015 14:31:44 UTC+1.

Hi Marcelo,

Try removing the leading slash from your paths, I think Tyk inserts a trailing slash to the listen path, so it might be matching the wrong paths.

Let me know if that helps.

Thanks,
Martin

Imported Google Group message.
Sender:Martin Buhr.
Date:Sunday, 26 April 2015 15:53:38 UTC+1.

Martin, I removed the leading slash but the issue remains. I did some more tests and I realized:
If I remove GET /documents, the path POST /documents begins to work. The main point is, only the first path works well, no matter if it is GET, POST, PUT or DELETE.

Thanks,
Marcelo

Imported Google Group message.
Sender:Marcelo.
Date:Sunday, 26 April 2015 15:57:50 UTC+1.

Hi Marcelo,

Thanks, I think you may have found a bug, let me investigate…

Thanks,
Martin

Imported Google Group message.
Sender:Martin Buhr.
Date:Sunday, 26 April 2015 16:04:57 UTC+1.

Hi Marcelo,

It would be really helpful if you could pull the actual API definition from Mongo? If you don’t want to or it publicly just email it to me directly.

Cheers,
Martin

Imported Google Group message.
Sender:Martin Buhr.
Date:Sunday, 26 April 2015 17:08:03 UTC+1.

Ok, having checked this it looks like a bug in the API designer, it’s storing the paths seperately in the version definition like this:

“white_list”: [
{
“path”: “widget/”,
“method_actions”: {
“GET”: {
“action”: “reply”,
“code”: 200,
“data”: “GET TEST”,
“headers”: {}
}
}
},
{
“path”: “widget/”,
“method_actions”: {
“POST”: {
“action”: “reply”,
“code”: 200,
“data”: “POST TEST”,
“headers”: {}
}
}
},
{
“path”: “widget/”,
“method_actions”: {
“PUT”: {
“action”: “reply”,
“code”: 200,
“data”: “TEST PUT”,
“headers”: {}
}
}
}
]

Those method definitions need to be under the path attribute, which is why it is failing on the subsequent requests (Tyk only matches the first found pattern), if those method mock objects are moved into the one path attribute it works.

This could be a translation issue in how the designer handles these objects (it’s quite a complex transformation)

We’ll fix it in the next version, in the mean time, I’d suggest manually adjusting those mocks or setting up the definition manually and importing it.

Thanks,
Martin

  • show quoted text -

Imported Google Group message.
Sender:Martin Buhr.
Date:Sunday, 26 April 2015 23:12:46 UTC+1.

Hi Martin,
Thanks for reply and support. Yes, I do think it is a bug. I did some tests and:

Using the Tyk Analytics, I have created these whitelisted endpoints.

GET /documents
POST /documents
PUT /documents
DELETE /documents.

And the result in API Definition on MongoDB was:

“extended_paths” : {
“ignored” : [ ],
“white_list” : [
{
“path” : “/documents”,
“method_actions” : {
“GET” : {
“action” : “no_action”,
“code” : 200,
“data” : “”,
“headers” : {
}
}
}
},
{
“path” : “/documents”,
“method_actions” : {
“POST” : {
“action” : “no_action”,
“code” : 200,
“data” : “”,
“headers” : {
}
}
}
},
{
“path” : “/documents”,
“method_actions” : {
“PUT” : {
“action” : “no_action”,
“code” : 200,
“data” : “”,
“headers” : {
}
}
}
},
{
“path” : “/documents”,
“method_actions” : {
“DELETE” : {
“action” : “no_action”,
“code” : 200,
“data” : “”,
“headers” : {
}
}
}
}
],
“black_list” : [ ],
“cache” : [ ],
“transform” : [ ],
“transform_headers” : [ ]
}

In this scenario, only GET /documents works ok, but for other methods, I have received “409 Conflict”. After that, as Martin suggested, I manually altered the API definition in MongoDB to this:

“extended_paths” : {
“ignored” : [ ],
“white_list” : [
{
“path” : “/documents”,
“method_actions” : {
“GET” : {
“action” : “no_action”,
“code” : 200,
“data” : “”,
“headers” : {
}
},
“POST” : {
“action” : “no_action”,
“code” : 200,
“data” : “”,
“headers” : {
}
},
“PUT” : {
“action” : “no_action”,
“code” : 200,
“data” : “”,
“headers” : {
}
},
“DELETE” : {
“action” : “no_action”,
“code” : 200,
“data” : “”,
“headers” : {
}
}
}
}
],
“black_list” : [ ],
“cache” : [ ],
“transform” : [ ],
“transform_headers” : [ ]
}

And then, everything has been working properly! For now I’ll manually edit my API definitions.

Martin, I’ll open an issue on github. Thank you!

Imported Google Group message.
Sender:Marcelo.
Date:Monday, 27 April 2015 11:48:46 UTC+1.

Just a note, this is now fixed in our master branch and will be aprt of v1.6

  • show quoted text -