'How to return a string response from a .NET Core API endpoint that has a quotations in it?
In order to subscribe to Strava's webhook, I need to return a specifically formatted string when they call my endpoint.
The string needs to look like this:
{ “hub.challenge”:”123” }
however when I actually try to return this, in the response it appears like this:
"{ \"hub.challenge\":\"123\" }"
This is my actual endpoint being called:
[HttpGet]
public OkObjectResult Get([FromQuery(Name = "hub.mode")] string mode,
[FromQuery(Name = "hub.challenge")] string challenge,
[FromQuery(Name = "hub.verify_token")] string verifyToken)
{
return Ok("{ " + $"\"hub.challenge\":\"{challenge}\"" + " }");
}
How can I return this string properly so it matches up with what Strava is looking for? Or is this simply not possible in C#.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
