Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Values not POSTing. Please help. #58

Open
neo302 opened this issue Dec 25, 2022 · 0 comments
Open

Values not POSTing. Please help. #58

neo302 opened this issue Dec 25, 2022 · 0 comments

Comments

@neo302
Copy link

neo302 commented Dec 25, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant