{"record":{"id":"f355b50bb5b057ce","repo":"reactiveui/refit","slug":"a-url-method-must-not-also-declare-a-path-templa","errorCode":null,"errorMessage":"A [Url] method must not also declare a path template; [Url] provides the full absolute URI, but the template was \"{relativePath}\".","messagePattern":"A \\[Url\\] method must not also declare a path template; \\[Url\\] provides the full absolute URI, but the template was \"(.+?)\"\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Refit.Reflection/RestMethodInfoInternal.ParameterBinding.cs","lineNumber":412,"sourceCode":"    }\n\n    /// <summary>Finds and validates the <c>[Url]</c> parameter that supplies the absolute request URI, ensuring the\n    /// method does not also declare a path template.</summary>\n    /// <param name=\"parameterArray\">The array of method parameters.</param>\n    /// <param name=\"sets\">The classified attribute set for each parameter.</param>\n    /// <param name=\"relativePath\">The method's relative path template.</param>\n    /// <returns>The index of the <c>[Url]</c> parameter, or a negative value when none is present.</returns>\n    /// <exception cref=\"ArgumentException\">More than one parameter carries <c>[Url]</c>, the parameter is not a\n    /// <see cref=\"string\"/> or <see cref=\"Uri\"/>, or a <c>[Url]</c> parameter is combined with a non-empty path\n    /// template.</exception>\n    internal static int ResolveUrlParameter(ParameterInfo[] parameterArray, ParameterAttributeSet[] sets, string relativePath)\n    {\n        var urlIndex = FindUrlParameter(parameterArray, sets);\n        if (urlIndex >= 0\n            && !string.IsNullOrEmpty(relativePath)\n            && relativePath != \"/\")\n        {\n            throw new ArgumentException(\n                $\"A [Url] method must not also declare a path template; [Url] provides the full absolute URI, but the template was \\\"{relativePath}\\\".\");\n        }\n\n        return urlIndex;\n    }\n\n    /// <summary>Finds the index of the <c>[Url]</c> parameter that supplies the absolute request URI.</summary>\n    /// <param name=\"parameterArray\">The array of method parameters.</param>\n    /// <param name=\"sets\">The classified attribute set for each parameter.</param>\n    /// <returns>The index of the <c>[Url]</c> parameter, or a negative value when none is present.</returns>\n    /// <exception cref=\"ArgumentException\">More than one parameter carries <c>[Url]</c>, or the parameter is not a\n    /// <see cref=\"string\"/> or <see cref=\"Uri\"/>.</exception>\n    internal static int FindUrlParameter(ParameterInfo[] parameterArray, ParameterAttributeSet[] sets)\n    {\n        var urlIndex = -1;\n\n        for (var i = 0; i < parameterArray.Length; i++)\n        {","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/reactiveui/refit/blob/b455f65ecc4c97d092317e349cb775f9cfc6bcdf/src/Refit.Reflection/RestMethodInfoInternal.ParameterBinding.cs#L394-L430","documentation":"A method that declares a [Url] parameter (which supplies the full absolute request URI) must not also declare a path template, because the two would conflict over what the request URL is. The guard allows an empty or '/' template only; anything else throws.","triggerScenarios":"An interface method has both [Url] on a parameter and a non-empty, non-'/' path such as [Get(\"/items/{id}\")].","commonSituations":"Adding a per-call base-URL parameter to a method that already had a route template; converting a fixed-URL method to [Url] without clearing the template.","solutions":["Remove the path template (use [Get(\"\")] or [Get(\"/\")] or an empty route) when using [Url].","If you need a relative path, drop [Url] and configure the base URL on the client/RefitSettings instead."],"exampleFix":"// before\n[Get(\"/items/{id}\")] Task GetAsync([Url] string url, int id);\n\n// after\n[Get(\"\")] Task GetAsync([Url] string url);","handlingStrategy":"validation","validationCode":"static void AssertUrlHasNoTemplate(MethodInfo m) {\n    var hasUrl = m.GetParameters().Any(p => p.GetCustomAttribute<UrlAttribute>() is not null);\n    var attr = m.GetCustomAttribute<HttpMethodAttribute>();\n    if (hasUrl && !string.IsNullOrEmpty(attr?.Path) && attr.Path != \"/\")\n        throw new InvalidOperationException(\"[Url] method must not also declare a path template.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use an empty/'/' route when declaring a [Url] parameter.","Set base URLs on the HttpClient rather than per-method [Url].","Review templates when adding [Url] params."],"tags":["refit","url","routing","attributes","design-time"],"backgroundTag":null,"analyzedSha":"b455f65ecc4c97d092317e349cb775f9cfc6bcdf","analyzedAt":"2026-08-13T21:20:57.878Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}