How to convert string to JSON String

I have string value in a variable (XYZ), passing this variable in the UiPath.web.activities.httpclient body as shown below, and body format is application/JSON
image

here is the post request method

public async Task test([FromBody] string teststringdata)
{
try
{

     using DBContext context = new();

     _ = await context.Database.ExecuteSqlRawAsync("EXEC [xyzStoredProcedure] @teststringdata", new SqlParameter[]
         {                 
             new("@testNotes", teststringdata)
         });

     return Ok();
 }

I’m getting 400 error message: “errors”:{“$”:[“‘N’ is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.”

Example string I’m passing from UiPath in variable XYZ: “NT:Test sending string to post method”

It basically saying the method I have accepts JSON String , not a raw string. So I need help on how I can convert the string value I have defined (XYZ) in UiPath to JSON String

Hey @sunit30
You should ensure the string is properly formatted as JSON.
Given the value of XYZ , you want to create a JSON object where XYZ is part of a key-value pair. Assuming the key should be teststringdata based on your function signature, you can format it like this in UiPath:
jsonString = "{""teststringdata"":""" + XYZ + """}"

{"teststringdata":"NT:Test sending string to post method"}