2

I am consuming an api, the guy working in the backend uses c# and he could not explain to me the methods other than his code. But I don't have experience in c#. Can someone translate to me these lines and tell me what is the url part and what are the body params if any. Thanks!

[WebInvoke(Method = "POST",
        UriTemplate = "UploadCat/{token}/{BID}/{CID}/{CAT}/{DATA}")]
        public HttpResponse UploadCat(string token, string BID, string CID, string CAT, List<CLMobileChangeDTO> DATA) 
elhoucine
  • 2,356
  • 4
  • 21
  • 37

1 Answers1

1

Depending on the encoding you could hit this API with curl like:

curl -X POST http://hostname/UploadCat/mytoken/myBID/myCID/myCAT/encodedDATA

The tricky part is how the framework you are using will encode a list of objects into URL safe characters to put it on the path. I don't think there is enough information in that code snippet to determine that.

Ideally you would use the post body to send List DATA instead of a path parameter.

  • Hi Ben thanks for your answer. Dou mean that is possible to send the params (myBID, myCID..) in the body as well as in the path? – elhoucine Jul 27 '17 at 09:09
  • Typically you would send a single object via the post body. Then you can use the path params to send each of those string parameters. –  Jul 28 '17 at 15:32