c# - How to write POST method with binary input for Microsoft Cognitive Service API -
microsoft cognitive services api supports 2 input methods within post body: raw image binary or image url. using online test console api, know http request should like.
`post https://api.projectoxford.ai/vision/v1.0/analyze?visualfeatures=faces http/1.1 content-type: application/json host: api.projectoxford.ai content-length: 125 ocp-apim-subscription-key: •••••••••••••••••••••••••••••••• {"url":"someimageurl"}`
i making request unitywebrequest , have far is
string url = "https://api.projectoxford.ai/vision/v1.0/analyze?visualfeatures=faces"; unitywebrequest www = new unitywebrequest(url, "post"); www.setrequestheader("content-type", "application/json"); www.setrequestheader("ocp-apim-subscription-key", apikey);
how include byte[] image request?
i have figured out www unity, not unitywebrequest.
i succeeded code:
// add www headers needed wwwform form = new wwwform(); var headers = form.headers; headers["content-type"] = "application/octet-stream"; headers["ocp-apim-subscription-key"] = key; //start www request www www = new www(url, image, headers); startcoroutine(waitforrequest(www));
Comments
Post a Comment