{"record":{"id":"101a115872f5e6f9","repo":"reactiveui/refit","slug":"url-parameter-param-name-must-be-of-type-str","errorCode":null,"errorMessage":"[Url] parameter \"{param.Name}\" must be of type string or System.Uri","messagePattern":"\\[Url\\] parameter \"(.+?)\" must be of type string or System\\.Uri","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Refit.Reflection/RestMethodInfoInternal.ParameterBinding.cs","lineNumber":444,"sourceCode":"    {\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":426,"sourceCodeEnd":454,"githubUrl":"https://github.com/reactiveui/refit/blob/b455f65ecc4c97d092317e349cb775f9cfc6bcdf/src/Refit.Reflection/RestMethodInfoInternal.ParameterBinding.cs#L426-L454","documentation":"A [Url] parameter must be a string or a System.Uri, because Refit constructs the request Uri from that value directly. Any other type (int, object, custom struct) cannot be used as an absolute URI source and is rejected.","triggerScenarios":"A parameter carries [Url] but its declared type is neither string nor Uri (e.g. int, Guid, a custom type).","commonSituations":"Mistakenly applying [Url] to an id or identifier parameter; refactor that changed the parameter type but kept [Url].","solutions":["Change the [Url] parameter type to string or Uri.","If the value is an identifier rather than a URL, remove [Url] and put it in the route template instead."],"exampleFix":"// before\n[Get(\"\")] Task GetAsync([Url] int endpointId);\n\n// after\n[Get(\"\")] Task GetAsync([Url] string url);","handlingStrategy":"type-guard","validationCode":"static void AssertUrlType(ParameterInfo p) {\n    var t = p.ParameterType;\n    if (p.GetCustomAttribute<UrlAttribute>() is not null && t != typeof(string) && t != typeof(Uri))\n        throw new InvalidOperationException(\"[Url] parameter must be string or Uri.\");\n}","typeGuard":"static bool IsUrlParameterType<T>() => typeof(T) == typeof(string) || typeof(T) == typeof(Uri);","tryCatchPattern":null,"preventionTips":["Declare [Url] parameters as string or Uri.","Use the route template for non-URL identifiers."],"tags":["refit","url","type-binding","attributes","design-time"],"backgroundTag":null,"analyzedSha":"b455f65ecc4c97d092317e349cb775f9cfc6bcdf","analyzedAt":"2026-08-13T21:20:57.878Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}