Forum Discussion

c0micrage's avatar
New Member
4 years ago

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

public IActionPost Post(MyDTO dto)
  // I can connect to this method

I have another that looks like this
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 
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

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

No RepliesBe the first to reply