{"record":{"id":"2766c0d3c5d044d7","repo":"reactiveui/refit","slug":"only-one-parameter-can-be-a-url-parameter","errorCode":null,"errorMessage":"Only one parameter can be a [Url] parameter","messagePattern":"Only one parameter can be a \\[Url\\] parameter","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Refit.Reflection/RestMethodInfoInternal.ParameterBinding.cs","lineNumber":439,"sourceCode":"    /// <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        {\n            var param = parameterArray[i];\n            if (sets[i].Url is null)\n            {\n                continue;\n            }\n\n            if (urlIndex >= 0)\n            {\n                throw new ArgumentException(\"Only one parameter can be a [Url] parameter\");\n            }\n\n            if (param.ParameterType != typeof(string) && param.ParameterType != typeof(Uri))\n            {\n                throw new ArgumentException(\n                    $\"[Url] parameter \\\"{param.Name}\\\" must be of type string or System.Uri\");\n            }\n\n            urlIndex = i;\n        }\n\n        return urlIndex;\n    }\n}\n","sourceCodeStart":421,"sourceCodeEnd":454,"githubUrl":"https://github.com/reactiveui/refit/blob/b455f65ecc4c97d092317e349cb775f9cfc6bcdf/src/Refit.Reflection/RestMethodInfoInternal.ParameterBinding.cs#L421-L454","documentation":"Refit allows at most one [Url] parameter per method, since a single request can have only one absolute target URI. The loop tracks the first [Url] index and throws when it encounters a second [Url] parameter.","triggerScenarios":"Two parameters on the same method both carry the [Url] attribute.","commonSituations":"Copy-paste of an existing [Url] parameter; attempting to provide both a base URL and a resource URL as two [Url] params.","solutions":["Keep a single [Url] parameter and compose the full URI (base + path) before calling.","If you need a configurable base, set it on the HttpClient/RefitSettings instead of a second [Url] param."],"exampleFix":"// before\n[Get(\"\")] Task GetAsync([Url] string baseUrl, [Url] string path);\n\n// after\n[Get(\"\")] Task GetAsync([Url] string fullUrl);","handlingStrategy":"validation","validationCode":"static void AssertSingleUrl(MethodInfo m) {\n    var count = m.GetParameters().Count(p => p.GetCustomAttribute<UrlAttribute>() is not null);\n    if (count > 1) throw new InvalidOperationException(\"Multiple [Url] params on \" + m.Name);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Allow one [Url] parameter per method.","Compose full URIs before the call when multiple URL parts exist.","Use HttpClient base address for configurable bases."],"tags":["refit","url","attributes","design-time"],"backgroundTag":null,"analyzedSha":"b455f65ecc4c97d092317e349cb775f9cfc6bcdf","analyzedAt":"2026-08-13T21:20:57.878Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}