0

I am building a application in android which would record the video, store it in local storage and send it for analysis to the Emotion API. However, I am unable to form the request body. I am using the following example: https://westus.dev.cognitive.microsoft.com/docs/services/5639d931ca73072154c1ce89/operations/56f8d40e1984551ec0a0984e/console

I just need to know how to form the request and for a video file.

1 Answers1

0

In addition to the comment by Maria, I tried the first two solutions from the following question:

How do I send a file in Android from a mobile device to server using http?

I would suggest to go through top 2 solutions, as they would most probably work. In RESPONSE, a Operation-Location and OID is received, to which a HTTP GET call can be made:

https://westus.api.cognitive.microsoft.com/emotion/v1.0/operations/{oid}

Documentation: https://westus.dev.cognitive.microsoft.com/docs/services/5639d931ca73072154c1ce89/operations/56f8d4471984551ec0a0984f

The code I used for GET request:

    URIBuilder statusBuilder = new URIBuilder("https://westus.api.cognitive.microsoft.com/emotion/v1.0/operations/{oid});
statusBuilder.setParameter("oid", {oid});

URI uriStatus = statusBuilder.build();
HttpGet statusRequest = new HttpGet(uriStatus);
statusRequest.setHeader("Ocp-Apim-Subscription-Key", {key});

HttpResponse statusResponse = httpclient.execute( statusRequest );
HttpEntity entity = statusResponse.getEntity();
Header[] statusHeaders = statusResponse.getAllHeaders();
    for (Header header : statusHeaders) {
        System.out.println( "Key : " + header.getName()
            + " ,Value : " + header.getValue() );
    }