Need example of how to pass Specflow's ScenarioContext stored value to API request body in C#
I'm using .NET Core, Specflow, Selenium and JSON for API testing. I'm passing a stored value into my request body using Specflow's ScenarioContext. The error I receive is "'{salesOrderType}' cannot be found in the system". Can someone provide an example of how to pass my salesOrderType value to the request body in C#?
Here's my stored values:
var salesOrderNumber = _scenarioContext["SalesOrderNumber"];
var salesOrderType = _scenarioContext["SalesOrderType"];
Here's my request body:
var body = @"{
" + "\n" +
@" ""entity"": {
" + "\n" +
@" ""OrderType"": {
" + "\n" +
$@" ""value"": ""{salesOrderType}""
" + "\n" +
@" },
" + "\n" +
@" ""OrderNbr"": {
" + "\n" +
$@" ""value"": ""{salesOrderNumber}""
" + "\n" +
@" }
" + "\n" +
@" }
" + "\n" +
@"}";
0
-
It turns out my code works fine in Dev but not QA, so it has nothing to do with my code but the environment.
0
Please sign in to leave a comment.
Comments
1 comment