cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Has anyone had luck using HTTP_REQUEST_METHOD in a Global Web Request Naming rule Placeholder?

NeJoyer
Observer

I have a REST service.


It gets requests like:
POST /users
and
GET /users

 

The GET returns a bunch of users, the POST creates a new user. So while the url is the same for each, the code that gets executed is very different.


I'd like to create a global web request naming rule that includes the http method in the web request name.
I think this should be possible.

In this document, it says that the placeholder attribute can be HTTP_REQUEST_METHOD (which I'm pretty sure is what I want).

But I'm having trouble crafting a payload to create a web request naming method that uses that value.

An example payload that I've tried is:

 

{
    "conditions": [{
            "attribute": "SERVICE_TAG",
            "comparisonInfo": {
                "comparison": "TAG_KEY_EQUALS",
                "negate": false,
                "type": "TAG",
                "value": {
                    "context": "CONTEXTLESS",
                    "key": "REST Cleanup With HTTP Method"
                },
                "values": null
            }
        }
    ],
    "enabled": true,
    "order": "REST 00",
    "managementZones": [],
    "namingPattern": "{HTTPMethod} {URL}",
    "placeholders": [
		{
			"aggregation": null,
            "attribute": "HTTP_REQUEST_METHOD",
            "delimiterOrRegex": null,
            "endDelimiter": null,
            "kind": "ORIGINAL_TEXT",
            "name": "HTTPMethod",
            "normalization": "ORIGINAL",
            "requestAttribute": null,
            "source": null,
            "useFromChildCalls": false
		},
		{
            "aggregation": null,
            "attribute": "WEBREQUEST_URL_PATH",
            "delimiterOrRegex": "(.*+)",
            "endDelimiter": null,
            "kind": "REGEX_EXTRACTION",
            "name": "URL",
            "normalization": "ORIGINAL",
            "requestAttribute": null,
            "source": null,
            "useFromChildCalls": false
        }
    ]
}

 

(I'm actually trying for something more complicated, which is why I have that regex for the second placeholder, but I tried distilling the example down for brevity).

 

That request gets me a couple of errors:

"path": "placeholders[0].attribute",
"message": "Placeholders are only allowed for string based attributes",

and

"path": "placeholders[0].kind",
"message": "ExtractionKind `ORIGINAL_TEXT` is only allowed for downstream request attribute placeholders. No extraction needs to be specified",

I'm really not worried about that second one... worst case I could make it a regex extraction and that would solve that problem.

However, that first error is the one that I'm most worried about.
Specifically, it seems to be complaining about my attribute: HTTP_REQUEST_METHOD and saying that isn't a string based attribute.

But according to the documentation I linked above, that should be a valid attribute.

 

Worse case I could create a rule so that it has a condition for HTTP_REQUEST_METHOD == GET, and then hardcode "GET" in the name... and repeat that for each of the other verbs... but that sounds tedious.

 

Any ideas? Thank you.

1 REPLY 1

Michał
Frequent Guest

I had same problem and solution is simple:
There are predefined placeholders with you can use. In this case placeholder to use:

{HTTP-Method} /sample/URL/


Featured Posts