1

I am trying to use Microsoft face API software in c#. The first step says I need to authorize the API read below for instructions:

Every call to the Face API requires a subscription key. This key needs to be either passed through a query string parameter, or specified in the request header. To pass the subscription key through query string, please refer to the request URL for the Face - Detect as an example:

https://api.projectoxford.ai/face/v1.0/detect[?returnFaceId][&returnFaceLandmarks][&returnFaceAttributes]&subscription-key=<Your subscription key>

As an alternative, the subscription key can also be specified in the HTTP request header: ocp-apim-subscription-key: <Your subscription key> When using a client library, the subscription key is passed in through the constructor of the FaceServiceClient class. For example:

faceServiceClient = new FaceServiceClient("Your subscription key");   

The subscription key can be obtained from the Marketplace page of your Azure management portal. See Subscriptions.

Now I am confused at how I would go about this. So first I tried using the query string way of doing it .

sing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using Microsoft.ProjectOxford.Face;
using Microsoft.ProjectOxford;
using System.Web;
using System.Web.UI;

namespace faceAPI
{
    class Program
    {
        string fullname1 = Request.QueryString["https://api.projectoxford.ai/face/v1.0/detect[?returnFaceId][&returnFaceLandmarks][&returnFaceAttributes]&subscription-key=<3ac0d7ef76274d59837a6c4ce60ce309>"];
        string fullname2 = Request["https://api.projectoxford.ai/face/v1.0/detect[?returnFaceId][&returnFaceLandmarks][&returnFaceAttributes]&subscription-key=<3ac0d7ef76274d59837a6c4ce60ce309>"];

        static void Main(string[] args)
        {

        }
    }
}

But after i do this i get an error saying :

Error 3 The name 'Request' does not exist in the current context

Luiso
  • 3,658
  • 2
  • 32
  • 57
Evan Arends
  • 69
  • 1
  • 4
  • `Request` is part of the HTTPContext object, which isn't going to be available when executing a console application. What you need to do in your program is create a `WebRequest` to call the web service. – DVK Jun 13 '16 at 18:56
  • WebRequest request = WebRequest.Create("https://api.projectoxford.ai/face/v1.0/detect[?returnFaceId][&returnFaceLandmarks][&returnFaceAttributes]&subscription-key=<3ac0d7ef76274d59837a6c4ce60ce309>"); I have tried doing this but not sure what to do with it after that – Evan Arends Jun 13 '16 at 19:32
  • Have you removed the `[ ]` form your urls? I think that url pieces inside the `[]` are meant to be used without them if used or removed if not used at all. – Luiso Jun 13 '16 at 19:42
  • I think the brackets are meant to be, i removed them and still got errors. – Evan Arends Jun 13 '16 at 19:52
  • @EvanArends the `[]` are not `HTTP URL` standard characters, however when describing command-line interfaces it is usual to wrap optional parameters in them, as is that identifiers are wrapped in `<>` as in ``. Please remove the `[]` and `<>`, in the case of `[]` remove the whole wrapped text as well and see if it works – Luiso Jun 13 '16 at 20:09
  • @Luiso still same errors as before none of that worked unfortuanately – Evan Arends Jun 13 '16 at 20:18

0 Answers0