Search code examples
azurehttp-headerspostmanazure-media-services

What is and how do I find the host URI in Microsoft Azure?


When looking at the REST API documentation from Microsoft, it shows that the headers for a specific request should include a host name. I'd like to know what this is and how do I find it?

Microsoft says that these are the request headers:
POST https://testrest.cloudapp.net/api/Channels('nb:chid:UUID:2c30f424-ab90-40c6-ba41-52a993e9d393')/Start HTTP/1.1  
DataServiceVersion: 3.0;NetFx  
MaxDataServiceVersion: 3.0;NetFx  
Accept: application/json;odata=minimalmetadata  
Accept-Charset: UTF-8  
x-ms-version: 2.11  
Content-Type: application/json;odata=minimalmetadata  
Host: <host URI>  
User-Agent: Microsoft ADO.NET Data Services  
Authorization: Bearer <token value>  

I'm having trouble connecting due to receiving a 400 error and without the Host URI. The reason I didn't use it at first is because Postman doesn't use one however their API call was successful. Does anyone know if the Host URI is necessary and if so, where can I find it in Microsoft Azure? Specifically for Media Services.


Solution

  • In Http 1.1, The Host header is necessary.

    Main points of Http:

     HTTP/1.0 does not bring host, and HTTP/1.1 adds host head.
    
     Host can be a domain name, or IP, or port number.
    
     Host can be customized by programs. Some programs can define false host in order to prevent operators or bypass firewalls.
    
     Host in HTTP/1.1 can be null value but not without. If no host head is taken, 400 Bad request will be returned.
    
     The HTTP response header does not contain the host field.
    
     Some sites do not check host and can pass arbitrary values.
    

    In Postman, it will automatically fills the host header with the host (domain name) in URL.

    In your case, we can fill the host header with testrest.cloudapp.net:433