-
-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Description
Hello,
For some reason I can't get the JSON values to post to a basic Net Core API.
I've tried the different methods APICaller_Web_Extended, APICaller_POST_Extended, etc., but still can't get the value to post to the API as I get an immediate reject.
Can someone please help?
DECLARE @httpMethod nvarchar(max) = 'POST'
DECLARE @url nvarchar(max) = 'https://localhost:42368/api/myapi'
DECLARE @headers nvarchar(max) = '[{
"Name": "Content-Type",
"Value" :"application/json; charset=utf-8"
}]';
Declare @cJSONbody NVARCHAR(MAX) = '{
"astring": "Foo"
}'
exec [dbo].[APICaller_POST_Extended]
@url
,@headers
,@JsonBody = @cJSONbody
API:
[HttpPost]
public async Task myapi(string astring)
{
try
{
var j = astring;
//....
return Ok("OK");
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, "Database Failure");
}
}
Error
Result:
{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"00-ebe41ad40e4609a7ba247b3c55687ca7-b98e61eaac0c50b3-00","errors":{"astring":["The astring field is required."]}}
ContentType:
application/problem+json; charset=utf-8
Metadata
Metadata
Assignees
Labels
No labels