yeah, classic RestSharp gotcha. AddJsonBody double-serializes strings. Use AddParameter instead: apiRequest.AddParameter("application/json", jsonData, ParameterType.RequestBody); - works every time. RestSharp can’t tell the difference between raw JSON strings and objects it needs to serialize.
I’ve hit this same issue with RestSharp’s AddJsonBody. The problem is AddJsonBody expects an object to serialize, not a JSON string that’s already serialized. When you pass a string, RestSharp treats it as a literal value and wraps it in extra quotes, which breaks your JSON. Use AddStringBody instead: apiRequest.AddStringBody(jsonData, DataFormat.Json);. Or better yet, create a proper object model and let RestSharp serialize it for you. Way more reliable than building JSON strings by hand. HttpWebRequest works because you’re writing the raw string directly to the request stream - no extra processing.
Had the exact same problem last month switching from HttpClient to RestSharp for a Notion integration. RestSharp’s AddJsonBody method automatically serializes whatever you pass to it - even strings that are already valid JSON. So when you pass your pre-serialized JSON string, RestSharp escapes the quotes and wraps it again. Creates malformed JSON that Notion’s API rejects. Easy fix - use AddBody instead and set the content type manually: apiRequest.AddBody(jsonData, ContentType.Json); This tells RestSharp to use your string as-is without messing with it. HttpWebRequest worked because it sends raw data straight to the stream without any serialization getting in the way.
RestSharp treats your JSON string like a regular string that needs serialization. Both solutions work, but manually handling these API quirks gets old fast.
I hit this same issue with a dashboard syncing data to Notion hourly. Wasted too much time debugging RestSharp vs HttpClient vs whatever library.
Ended up automating it instead. Now I send data to a workflow that handles all Notion API calls. No JSON parsing headaches or library compatibility issues. The workflow handles formatting, errors, retries - everything.
Way better than maintaining custom API code. When Notion updates their API, I just update the workflow instead of digging through application code.