cancel
Showing results for 
Search instead for 
Did you mean: 

React js Swagger connecting to the correct HTTPPOST method

Highlighted
New Member

React js Swagger connecting to the correct HTTPPOST method

I am writing a reactjs page which uses swagger to connect to a webapi and hits the correct HTTPPOST method.

In the WebAPI there are multiple HTTPPOst methods like so

classname is MyClassController where 'MyClass' is referenced in the swagger call

[HttpPost]
public IActionPost Post(MyDTO dto)
{
  // I can connect to this method
}

I have another that looks like this
[httpPost]
[ActionName("AddAnotherDto")]
[Route("addAnotherDto")]
public ActionResult<IEnumerable<MyObjects>> AddAnotherDto(MyDTO dto)
{
  // I could not connect to this method
}
    

From my reactjs code, I used the following swagger call to connect to the API

this.state.swagger[tag][`${func}_${tag}`]({}, {request: body}')

I can successfully call the the 1st HttpPost method where 
tag='MyClass'
func='post'
body is my data json object

However, when I try to call the 2nd Post call, it can't get it to connect I tried the following with this call

this.state.swagger[tag][`${func}_${tag}`]({}, {request: body}')

tag='MyOjbect' // this is my API Controler name 
func='post login'
also tried
func='login'

Nothing work so far to try to connect to an API with multipled POST methods.

My assumption is that

swagger tags is the API classname func is the Http call type ie GET, POST, DELETE, PUT

How do I call between different POSTs?

Any help is appreciated. Thanks

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors