C
C#14mo ago
Natty

❔ [FromBody] and async issues...

I have this code:
public DataFactoryController(AppIdealContext db)
{
_db = db;
_client = CreateClientAsync().GetAwaiter().GetResult();
}

[HttpPost("TriggerPipelineOne")]
public async Task<IActionResult> TriggerPipelineOneAsync([FromBody] PipelineOneUserSettingsRequest request)
{
var userSettings = ConvertUserSettingsObjectToDictionary(request);
string pipelineOne = Environment.GetEnvironmentVariable(PIPELINEONENAME);
return await TriggerPipelineAsync(pipelineOne, PipelineStatusOptions.StartedPipelineOne, userSettings);
}
public DataFactoryController(AppIdealContext db)
{
_db = db;
_client = CreateClientAsync().GetAwaiter().GetResult();
}

[HttpPost("TriggerPipelineOne")]
public async Task<IActionResult> TriggerPipelineOneAsync([FromBody] PipelineOneUserSettingsRequest request)
{
var userSettings = ConvertUserSettingsObjectToDictionary(request);
string pipelineOne = Environment.GetEnvironmentVariable(PIPELINEONENAME);
return await TriggerPipelineAsync(pipelineOne, PipelineStatusOptions.StartedPipelineOne, userSettings);
}
When I remove all the async stuff and make it void etc. then my FromBody works when deployed app in Azure environment. However, with the current code, I keep getting different JSON error messages in the console (even when using the same exact data each time). It seems like it's not getting the full data or something, like it's cut off at different parts, hence the different json error messages. Any ideas?
2 Replies
Natty
Natty14mo ago
Think I'll just need to make a separate synchronous endpoint save the FromBody data to the database, not elegant but idk.
Accord
Accord14mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.