Azure Media Services AssetDeliveryPolicies in REST Api - do they gone? - rest

I'm writing application in which i upload video, encode it, and then i need to expose a link to encoded video. One of the steps is to create AssetDeliveryPolicies and link it to Asset, i tried to do that, but to my surprise i don't see such entity as AssetDeliveryPolicies on that endpoint:
https://wamsamsclus001rest-hs.cloudapp.net/api/AssetDeliveryPolicies
Do anybody have tried to do something like that? I'm not sure whether i'm doing something wrong or it is already deprecated and handled in some other way.

Create an AccessDeliveryPolicy
POST https://media.windows.net/api/AssetDeliveryPolicies HTTP/1.1
Content-Type: application/json
DataServiceVersion: 1.0;NetFx
MaxDataServiceVersion: 3.0;NetFx
Accept: application/json
Accept-Charset: UTF-8
Authorization: Bearer [token here]
x-ms-version: 2.11
x-ms-client-request-id: [guid here]
Host: media.windows.net
{"Name":"Clear Policy",
"AssetDeliveryProtocol":7,
"AssetDeliveryPolicyType":2,
"AssetDeliveryConfiguration":null}
Link an AssetDeliveryPolicy to an Asset.
POST https://media.windows.net/api/Assets('nb%3Acid%3AUUID%3A86933344-9539-4d0c-be7d-f842458693e0')/$links/DeliveryPolicies HTTP/1.1
DataServiceVersion: 1.0;NetFx
MaxDataServiceVersion: 3.0;NetFx
Accept: application/json
Accept-Charset: UTF-8
Content-Type: application/json
Authorization: Bearer [token here]
x-ms-version: 2.11
x-ms-client-request-id: [new guid here]
Host: media.windows.net
{"uri":"https://media.windows.net/api/AssetDeliveryPolicies('nb%3Aadpid%3AUUID%3A92b0f6ba-3c9f-49b6-a5fa-2a8703b04ecd')"}
Where nb%3Acid%3AUUID%3A86933344-9539-4d0c-be7d-f842458693e0 is the URL Encoded value of AssetId and nb%3Aadpid%3AUUID%3A92b0f6ba-3c9f-49b6-a5fa-2a8703b04ecd is the URL Encoded value of the AccessDeliveryPolicy Id.
Source

Related

How to format responses of ec2 endpoint to json

I am trying to perform a GET-Request to the ec2-Endpoint https://ec2.eu-central-1.amazonaws.com/?Action=DescribeInstances&Version=2016-11-15 in order to get a list of all ec2 instances within my aws account (in eu-central-1 region). Unfortunately the response's content is formatted in xml. Is there a chance to change the format of the response to json?
I've already set the GET-Request's Accept-Header to "application/json" but without success.
If I query the iam-endpoint https://iam.amazonaws.com/?Action=ListUsers&Version=2010-05-08 with the same Accept-Header the response's content is being delivered properly in json string format.
These are the headers for the ec2-query (not working):
GET /?Action=DescribeInstances&Version=2016-11-15 HTTP/1.1
Host: ec2.eu-central-1.amazonaws.com
Accept: application/json
Content-Type: application/x-www-form-urlencoded
X-Amz-Date: 20180706T091958Z
Authorization: <valid AWS4 authorization header>
Cache-Control: no-cache
Postman-Token: 69c8f349-95b5-4e9d-991c-5ce2a55b0cbe
And the headers of my iam-query (working):
GET /?Action=ListUsers&Version=2010-05-08 HTTP/1.1
Host: iam.amazonaws.com
Accept: application/json
Content-Type: application/x-www-form-urlencoded
X-Amz-Date: 20180706T092222Z
Authorization: <valid AWS4 authorization header>
Cache-Control: no-cache
Postman-Token: ad86f2ae-870c-4289-a9d3-1f2ad9082c8f
Executing aws cli tools command aws ec2 describe-instances lists all instances in json format, so I think there should be a way to achieve this with a GET-request.
Thank you very much for your help.
Probably too late, but might help others.
I also tried to get json output from DescribeInstances without luck.
It seems to be impossible at the moment, since even aws cli receives it in xml and then converts it to json. You can see it using --debug flag:
aws ec2 describe-instances --debug

Performance Center API to upload script

I'm developing a Java tool using HttpClient to programmatically upload a VuGen script to Performance Center. What my tool do are:
Authenticate and save session cookie - /LoadTest/rest/authentication-point/authenticate
Upload the script - /LoadTest/rest/domains/[MyDomain]/projects/[MyProject]/Scripts
Log out - /LoadTest/rest/authentication-point/logout
http://alm-help.saas.hpe.com/en/12.53/api_refs/Performance_Center_REST_API/Performance_Center_REST_API.htm#scripts.htm
Authenticate and Log out step are working correctly. Namely, I can get session cookie from authentication and set cookie to be expired when logging out. However, at the upload script step, I always get HTTP 401 error. This is an error message:
401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the
credentials that you supplied.
This is what I sent to the Performance Center server.
POST http://[PC-Host]/LoadTest/rest/domains/[MyDomain]/projects/[MyProject]/Scripts HTTP/1.1
Content-Type: multipart/form-data
Content-Length: 31367
Host: [PC-Server]
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_111)
Cookie: LWSSO_COOKIE_KEY=1y8TbNawvT976BENi4oT1hW6_dCMwcz-eohdFDqWpfIXsW2tUMYHZuHZbUBg9wFQwFnQgfetx5I2EvCfaA5y-g..; QCSession=NjA3NTY5O0JWK0ZjSExzWStwTFZPd2xZSXZ5VlEqKjtQQyBSRVNUIEFQSSBDbGllbnQ7IDsg
Accept-Encoding: gzip,deflate
--_NK2aWTiwhT6VV0TIxkUIaHRx0GhDBZ2LOsY8
Content-Disposition: form-data; name="xml"
Content-Type: application/xml; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
<Script xmlns="http://www.hp.com/PC/REST/API"><TestFolderPath>Subject\DEV\abc</TestFolderPath><Overwrite>true</Overwrite><RuntimeOnly>true</RuntimeOnly><KeepCheckedOut/></Script>
--_NK2aWTiwhT6VV0TIxkUIaHRx0GhDBZ2LOsY8
Content-Disposition: form-data; name="file"; filename="abc.zip"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
## binary of zipped vugen script ##
--_NK2aWTiwhT6VV0TIxkUIaHRx0GhDBZ2LOsY8--
I have no idea what I'm doing wrong. Do you have any ideas?
Problem solved. XML encoding was to to blame.
I also moved to requests toolbelt to have more control on the multipart structure.

Rest call for "Media Encoder Standard" in azure ?

I'm using "Azure Media Encoder" to encode the video uploaded for streaming using below REST API call
GET https://wamsbayclus001rest-hs.cloudapp.net/api/MediaProcessors()?$filter=Name%20eq%20'Azure%20Media%20Encoder' HTTP/1.1
DataServiceVersion: 1.0;NetFx
MaxDataServiceVersion: 3.0;NetFx
Accept: application/json
Accept-Charset: UTF-8
Authorization: Bearer http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=amstestaccount001&urn%3aSubscriptionId=f7f09258-6753-4ca2-b1ae-193798e2c9d8&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&Audience=urn%3aWindowsAzureMediaServices&ExpiresOn=1421675491&Issuer=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&HMACSHA256=9hUudHYnATpi5hN3cvTfgw%2bL4N3tL0fdsRnQnm6ZYIU%3d
x-ms-version: 2.11
Host: wamsbayclus001rest-hs.cloudapp.net
I got a suggestion to use "Media Encoder Standard" instead of "Azure Media Encoder" to reduce the encoding cost. Is there any REST API call for Media Encoder Standard ? I did't find any.
GET https://media.windows.net/API/MediaProcessors HTTP/1.1
Content-Type: application/json;odata=verbose
Accept: application/json;odata=verbose
DataServiceVersion: 3.0
MaxDataServiceVersion: 3.0
x-ms-version: 2.11
Authorization: Bearer
will return a list of all supported media processors which you can use. Select appropriate based on your job.
https://msdn.microsoft.com/en-us/library/azure/hh973617.aspx is a Azure Media Services REST API reference page
https://msdn.microsoft.com/en-us/library/azure/hh973619.aspx contains various task presets for individual encoders

OneDrive REST API - Upload - Content of .png file converted to jpeg

When using the OneDrive REST API to upload files, the content of some files with a .png extension is automatically converted to JPEG. I'm able to reproduce the problem with both documented upload methods.
Sample png files:
http://www39.zippyshare.com/v/59255310/file.html
http://www2.zippyshare.com/v/11270772/file.html
For reference the shortened requests:
PUT method
PUT https://apis.live.net/v5.0/folder.<removed>/files/i2.png HTTP/1.1
Pragma: no-cache
<removed - no Content-Type header>
Content-Length: 33579
Host: apis.live.net
When the Content-Type in the header of the PUT request is set to application/octet-stream the following error is returned:
HTTP/1.1 415 Unsupported Media Type
Server: Live-API/19.7.925.4009 Microsoft-HTTPAPI/2.0
<removed>
{
"error": {
"code": "request_body_invalid_media_type",
"message": "The Content-Type header 'application/octet-stream' isn't supported."
}
}
POST method
POST https://apis.live.net/v5.0/folder.<removed>/files HTTP/1.1
Content-Type: multipart/form-data; boundary=735b1931-a2bb-4970-8142-373848528fcb
<removed>
Content-Length: 33767
Host: apis.live.net
--735b1931-a2bb-4970-8142-373848528fcb
Content-Disposition: form-data; name="file"; filename="i2.png"
Content-Type: application/octet-stream
.PNG<removed>
--735b1931-a2bb-4970-8142-373848528fcb--
Other OneDrive APIs
The problem does not happen with the API (skyapi.onedrive.live.com/API/2) Microsoft is using on the OneDrive website and in the Windows desktop client (skydrive.exe).
OneDrive developers:
Instead of returning a 415 error in the PUT request, would it be possible to support requests where the Content-Type: application/octet-stream header is set? In this case the data should be left as is without doing any data conversion. Thank you.
This is documented behaviour as per http://msdn.microsoft.com/en-us/library/dn659726.aspx (see the first note under uploading).
If you want to disable conversion, you can set downsize_photo_uploads=false in your query string.

Server does not accept my multipart/form-data

I try to upload an image to my webservice from my iphone application. The webservice is programmed in php. I have to send the image along with a device_id as multipart/form-data.
Something is wrong with my request because the server does not accept my device_id (invalid format). I am 100% positive that the device_id is correct because it works with my other requests.
I think there is something wrong with my request structure because Charles proxy cannot decode the multipart form-data.
Here is my request (sniffed with charles proxy):
POST /api/profile/update HTTP/1.1
Host: THE_URL
User-Agent: SeduceMe/1.0 CFNetwork/548.0.3 Darwin/11.2.0
Content-Length: 6639
Accept: */*
Content-Type: multipart/form-data; boundary=---------------------------255141413922088
Accept-Language: de-de
Accept-Encoding: gzip, deflate
Cookie: PHPSESSID=tlcpnqugcpgs0skh3l2ip9ujh7
Connection: keep-alive
Proxy-Connection: keep-alive
---------------------------255141413922088
Content-Disposition: form-data; name="device_id"
mgs2AHyvfIcSXHSKE+0eHA==
---------------------------255141413922088
Content-Disposition: form-data; name="form[file]"; filename="avatar.jpg"
Content-Type: image/jpeg
RAW_JPEG_DATA
---------------------------255141413922088--
there is a great wrapper to post form/data. it is ASIHTTPRequest
please look at ASIFormData
thanks/