2

I am calling a post method from one API to other in C# and getting a 404 Not Found error. When i look at the request message the request Uri looks good but Absolute Uri and Absolute path has some special characters inserted

This is how im calling the end point

var baseUrl = https://services.abc.com:1232/something;     
HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, $"{baseUrl}/v1/​abc/add");
requestMessage.Content = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");
Task<HttpResponseMessage> response = client.SendAsync(requestMessage);
Dee
  • 111
  • 2
  • 9

1 Answers1

3

%E2%80%8B encodes (for example according to this site) Zero-width space (U+200B) space character which is not shown by Visual Studio (I assume you use it). Try deleting /abc/ part and retyping it manually (or try copying this - $"{baseUrl}/v1/abc/add"), it seems that you have managed to copy-paste the character from somewhere.

Also answer to Zero Width Space character in string literals: Detect and/or prevent can be useful.

Guru Stron
  • 102,774
  • 10
  • 95
  • 132