Authentication for Stream Analytics REST Api
Hi there,
I am trying to use the stream analytics rest api from a java client. For other services (storage services for example), I am able to successfully use mutual certificate authorization. I create a management certificate using keytool and upload it through
the settings tab in azure portal. I then create an SSLContext from this certificate. This all works and I am able to get access to the storage services api.
The same flow does not seem to work for stream analytics api. When attempting to make an api call, I get 401 error code with the following response authorization header.
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.StreamAnalytics/streamingjobs?api-version=2014-10-01-preview
WWW-Authenticate=[Bearer authorization_uri="https://login.windows.net/{...}", error="invalid_token", error_description="The access token is missing or invalid."]
The result is the same whether or not I configure the certificate on the client side. So, it seems like the mutual certificate authorization is not supported in stream analytics as it is in the other management APIs. Can you confirm if this feature is not
supported? If it is not supported, can you please provide some information on how we should be authenticating for stream analytics REST api?
Thanks
I did some more investigating. The Azure Stream Analytics REST Api documentation uses
https://management.azure.com/
as the base uri for managing stream analytics service. The .NET azure sdk source code on github, however, uses
https://management.core.windows.net/
for the same. So, I have tried accessing some different variations of resources.
https://management.core.windows.net/{my subscription id}/services/storageservices
Response: 200 OK
Here, I am using mutual certificate authorization to successfully reach storage services at management.core.windows.net. This verifies that the certificate authorization flow works for other services in the same subscription.
https://management.azure.com/subscriptions/{my subscription id}/resourcegroups/StreamAnalytics-Default-Central-US/providers/Microsoft.StreamAnalytics/streamingjobs?api-version=2014-10-01-preview
Response: 401 Unauthorized
Message: {"error":{"code":"AuthenticationFailed","message":"Authentication failed. The 'Authorization' header is not present or provided in an invalid format."}}
Now I attempt to use the same mutual certificate authorization on the management.azure.com base uri for stream analytics management. The request fails and the error message notes that an expected Authorization header is missing. This leads me to
believe that mutual certificate authorization is not supported on management.azure.com.
The Authorization header makes sense for OAuth2 flow, so I am thinking that management.azure.com
might only support OAuth2. I need server to server management, so OAuth2 flow will not work because it requires interactive browser redirect to work with management api. Active
Directory only gives delegate permissions to management services, not application permissions. I believe this rules out using OAuth2 / Active Directory for headless
authorization - please correct me if I am wrong.
https://management.core.windows.net/subscriptions/{my subscription id}/resourcegroups/StreamAnalytics-Default-Central-US/providers/Microsoft.StreamAnalytics/streamingjobs?api-version=2014-10-01-preview
Response: 403 Forbidden
Message: <Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Code>ForbiddenError</Code><Message>The server failed to authenticate
the request. Verify that the certificate is valid and is associated with this subscription.</Message></Error>
Here I try to use the mangagement.core.windows.net base uri that is used in .net sdk. I get a 403 forbidden response. The error message indicates that the server attempted to complete the mutual certificate authorization. The server complains, though,
that the certificate is invalid. This is the same certificate used successfully to manage storage services, so I know the certificate is valid and the client flow works.
It would be great if someone could expand on the discrepancy between the base uri in the documentation vs .net sdk and provide some guidance on server to server authorization to stream analytics management api.
Thanks,
Dave
Similar Messages
-
Which Objects should I target for integrating Eloqua REST API 2.0?
Which Objects should I target for integration? and What are the possible use cases for the additional objects other than core objects?
I am still trying to find a good REST API 2,0 document like the Bulk 2.0 document. Book List: Oracle Marketing Cloud
I did find this but is also not in depth:
REST API - Documentation for Core Objects -
Best practice for development using REST API - OData
Hi All, I am new to REST. I am a developer who works mostly in server-side code using Visual Studio. Now that Microsoft is advocating to write code using REST API instead of server-side code or client side object model, I am trying to use REST API.
I googled and most of the example shows to write a code and put it on Content Editor/Script Editor. How to organize code and deploy to the staging/production in this scenario? Is there any Best Practice or example around this?
Regards,
KhushiIf you are writing code in aspx or cs it does not mean that you need to deploy it in the SharePoint server, it could be any other application running from your remote server. What I mean it you can use C# & Rest API to connect to SharePoint server.
REST API in SharePoint 2013 provides the developers with a simple standardized method of retrieving information from SharePoint and it can be used from any technology that is capable of sending standard HTTP requests.
Refer to the following blog that provide your more details about comparison of the major features of these programming choices/
http://msdn.microsoft.com/en-us/library/jj164060.aspx#RESTODataA
http://dlr2008.wordpress.com/2013/10/31/sharepoint-2013-rest-api-the-c-connection-part-1-using-system-net-http-httpclient/
Hope this helps
--Cheers -
Are there REST APIs to retrieve entity metadata for eloqua objects?
There is a list of all the objects which can be accessed by REST for CRUD in this link: REST API - Documentation for Core Objects under the Core Objects section.
For each of the objects listed under the Core Objects section are there is a field metadata under the Properties section.
For example for Email object, REST API - Accessing Emails , under the Properties section, there corresponding entries for fields of Emails object under the
Name ,Type, Description and Validations headings.
Is there a REST API for retrieving the same information i.e. the field metadata for an eloqua object programmatically ?
If not , it is a serious hindrance to building systems that are metadata driven and also since SOAP support is being deprecated...Metadata is 'top level' information on the object, and available whether you query the individual object (a single form, or email asset) or query for multiple objects of that type (list all forms, list all emails). Consider using a depth of minimal or partial for faster performance if the specific configuration of those objects is not important..
Example:
GET /assets/forms?depth=minimal&count=2
Returns:
"elements":
"type":"Form",
"currentStatus":"Draft",
"id":"19",
"createdAt":"1409623550",
"createdBy":"8",
"depth":"minimal",
"folderId":"7",
"name":"zzztestCS_3-9381543541_AutocompleteTest",
"permissions":"fullControl",
"updatedAt":"1409623623",
"updatedBy":"8"
"type":"Form",
"currentStatus":"Draft",
"id":"22",
"createdAt":"1409781207",
"createdBy":"11",
"depth":"minimal",
"folderId":"466",
"name":"daisychain1",
"permissions":"fullControl",
"updatedAt":"1412779449",
"updatedBy":"20"
"page":1,
"pageSize":2,
"total":130
Without limiting the count to 2, this would return up to 1000 results if you had multiple forms in your system and give you a basic top level view of each. Similarly, you can use GET /assets/form/{id}?depth=minimal to get the same sort of information.
Other endpoints can be found on the REST livedocs page here (requires authentication):
https://secure.eloqua.com/api/docs/Dynamic/Rest/1.0/Reference.aspx
Regards,
Bojan -
OneDrive for Business REST API - PUT,POST - 401 Unauthorized
Hi,
We've a trial version of Microsoft azure and are playing with the One drive for Business CRUD operations via the REST
API from java client as per the link : https://msdn.microsoft.com/en-us/office/office365/api/files-rest-operations
After getting the token, i'm able to list any folder, download file and get attributes of a file using GET successfully.
But, the operations such as PUT, POST which are required for create folder, upload file, rename file/folder, etc are not working. I get back "401 UnAuthorized" error.
Error Response json :
{"error":{"code":"-2147024891, System.UnauthorizedAccessException","message":"Access denied. You do not have permission to perform this action or access this resource."}}
I set the access token in the similar way how i set for GET in the http request and i'm using jboss rest easy client for accessing the rest API
Here is a code for "Creating a folder"
ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
ResteasyProviderFactory.pushContext(javax.ws.rs.ext.Providers.class, factory);
ResteasyClientBuilder resteasyClientBuilder = new ResteasyClientBuilder().providerFactory(factory);
ResteasyClient client = resteasyClientBuilder.build();
ResteasyWebTarget target = client.target(BASE_URL + "/getByPath('/TestFolder1')");
Invocation.Builder request = target.request();
request.header("Authorization", "Bearer " + this.token);
Response response = request.put(Entity.text(""));
And as per documentation, 401 UnAuthorized error means "Required authentication information is either missing or
invalid."
Am i missing any header that's supposed to be in the request/ Any other issue with the request?
Thanks,
KathirHi Kathir,
Here's the official document about "X-RequestDigest":
https://msdn.microsoft.com/en-us/library/jj164022(office.15).aspx#WritingData
In addition, here's an example header information which works for me :
Referer: https://xxxxxxxx.sharepoint.com/
Accept: application/json;odata=verbose
Accept-Language: en-US,en;q=0.8,zh-Hans-CN;q=0.5,zh-Hans;q=0.3
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: xxxxxxxx.sharepoint.com
Content-Length: 83
X-RequestDigest: 0x4F26025E572CD220FBBAAD26654318A0B771CF72B09C0BFC45AFF8F1B2B301968040BC16377159210B4D7451BAD63BC93A406BF2357807E86BBD9BFF1EC5FB31,09 Apr 2015 13:31:50 -0000
Cookie: FedAuth=77u/PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48U1A+RmFsc2UsMGguZnxtZW1iZXJzaGlwfDEwMDM3ZmZlODU1NmRmYTJAbGl2ZS5jb20sMCMuZnxtZW1iZXJzaGlwfHJla2VubGl1QG8zNjVlM3cxNS5vbm1pY3Jvc29mdC5jb20sMTMwNzM0NjU5MzE5ODYyNTE2LEZhbHNlLGU5VkJQdk83UStLVDh4Z3poSEp3WWRwS2NUY1FuUlNFYjI3anpRMktIbzh0WWN0YVhNcEMzRjh3Z1hLeEJyQy9wSFBzR3NIeHViUnlqcEZTZFp6aFN4S0VFNmFaT3BBcGN3RUJWL2dyUXVHQ2VocmdQTmVFYUxXMGNxOWhYVnV5UXV5Qyt3MDg5MFVhKytnamZGVTNCZjRQT1lMV09QWGR1OG5FRCswUUdTdlZGTCtGdURHUisrMUltYUE2Nk5ITHh3TWpzTnN3UlFaN09VVytJb3RQNzhrV0hDcWZmbUt3TDZQVkRoMUJTdjd2amdraG9xaGRUTlVXNDFwWUpWZUVtdGE3SWk3WVAwalJSMkhteVNnclNEL0I0dnVQUzdheXRQNU5TaEVmSzg3UWl4Y2RUUm9jcE1XYkMvR2UrV2VmeDN1RHRJeWM3ZG4yNm80WVErYmkxdz09LGh0dHBzOi8vbzM2NWUzdzE1LnNoYXJlcG9pbnQuY29tLzwvU1A+; d7cc986c54074ba596c0f3f0c6a07e93c796165acdb446f0984f8653a924f5d0i%3A0%23%2Ef%7Cmembership%7Crekenliu%40o365e3w15%2Eonmicrosoft%2Ecom=0; SearchSession=3a9a1891%2D2085%2D4317%2Dae7d%2D358347ff5be6; WSS_FullScreenMode=false; d7cc986c54074ba596c0f3f0c6a07e93b4f54f20f4c04590a868420e78a3abbd=%3Ci%20p%3D%22d22c909f%2Dae4e%2D42e9%2D82ab%2Dbe906418413e%22%20m%3D%22lN63W5c9pPYyHWKxxdMl6WGWh6W6TASoSI78S9d1Uc0%3D%22%20%2F%3E; _InfoPath_Sentinel=1; _InfoPath_CanaryValueAGATTETXKDJ6KT4YXQ7Z6AULOUFCEL2MNFZXI4ZPJRXWGYLUNFXW44ZPJF2GK3JPORSW24DMMF2GKLTYONXCW3TQOVRU45KPMNKDI42KJJVU6TJYJ5UW65SWOB2EIVTMOZ3TEVTLOZYXOVSHPE2UK4BUJU=jkwaTNwRGHKjf96CdilK1qmjja8eMACiZvpNPbf6MqN+JaJ50wJVlC8//+5LQd5vHu1g5hM19pyNKgu7mkjxHw==|635641728335513421; rtFa=DbSfJe2tMA+9NtxyLWKWXkI6P5gUPQNGv+VYIvKXiLoX3B2zsHXjfIA5BgjT/aafd0uMETloZVbS+6Ks9Op+Epaiz9uAN3sCSpREr/K2URBpcO/8Io8CIv0SG8T0LpH+gTnEdL+Pa8cyGsqHuL1kUMjZoc7Qq07cqiwn1NO8bkyxK6HFXg+0bs7vqhTGAnZDYfUg2WG7WMWGk1QxxswZVQrnwBBInvGIIipzc7BJ9lu9XBmbfGDB+tgU78AsKS6BRDRdgSmPXq1ftMDTOACyzdHKrEUxJN5s2N6AOsujcDaFFyn8466SVD9zPxthkCDW+RDBJDIEinfW+UVPF8hmrz3gO/c3+OkH1pt65b3ydbcIQAWE9249X3nszh9KJSIzIAAAAA==
I don't think it is related to a trial version. Please check whether you have missed the "User-Agent" header. I suggest you first test it with JS in your environment.
Thanks,
Reken Liu
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected]. -
Accessing sharepoint REST api using S2S authentication
Hi, I'm trying to access the SharePoint REST APIs (One-Drive for business) using the access token retrieved from S2S authentication flow (https://msdn.microsoft.com/en-us/library/azure/dn645543.aspx).
Currently, I'm getting the following exception:
he server was unable to process the request due to an internal error. For more information about
the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the
Microsoft .NET Framework SDK documentation and inspect the server trace log
Is this scenario (app auth instead of delegate auth) support for those set of APIs?
ThanksHi,
According to your description, my understanding is that you want to access SharePoint Online One-Drive for business API using OAuth 2.0 authentication.
In summary, Rest API can work with OAuth 2.0 authentication.
Here are some detailed articles about access Rest API with OAuth 2.0 authentication:
OAuth 2.0 Compliant REST API
Securing RESTful Web Services with OAuth2
About accessing One-Drive for business with Rest API, you can refer the article below:
Access OneDrive for Business using the SharePoint 2013 APIs
About the error message, I suggest you can use Fiddler to track the web request to find detailed message:
Fiddler
Thanks
Best Regards,
Jerry Guo
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
What is the best way to get storage data for hard disk using REST api
Hello All,
Given that I have disk info for virtual machine/role from service management REST api (for example using
GetRole) how I could retrieve container/blob related info for it?
So I have credentials for service management REST API, I have OSVirtualHardDisk info, but I am not sure how to detect correctly to which storage account connect and than which container to use. Yes, I know that there is OSVirtualHardDisk .MediaLink property
which contains storage account name and container inside of it but I am not sure it is good practice to assume about it format. Alternatively I have another solution - just retrieve all storage accounts from Service management REST, then compare url
of each account with disk's MediaLink. And use appropriate storage account for further data retrieve. But seem to me it could retrieve too many info.
So generally I am trying to find correct way to join service management REST api and Storage Services REST API for disksHi,
From my experience, your first approach is correct. The media link exactly points to the location of the blob. With the link, you can access the blob if you have the storage account key. If you want to extract more information, such as what
the container is and what the blob is, you can parse the link.
>> From my point of view it is bad way to retrieve storage account name and container.
In addition, you are welcome to post feature requests on
http://feedback.windowsazure.com/forums/34192--general-feedback
Best Regards,
Ming Xu
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Are there any published Java wrapper classes for the WebI RESTful API? Or do I have to manually write and parse JSON/XML?
Hello Jean-Philippe,
I can just give you my personal point of view if you're interested in.
Moving to RESTful is not just a technology change but a deep paradigm change. I think having a kind of wrappers based on legacy approach would be slow, error-prone and will not cover all the new features delivered in BI4.
I feel that trying to wrap every RESTful call offered (the number of supported operations is huge) in a generic way is not the most efficient to answer to a specific application. It will be faster to just grab the needed information and process it for a specific usecase.
The API offered (first came with 4.0 SP5) is stable (still anwering in the same way).
Because each developer has his/her own mindset, I don't expect that everybody will love to work with a RESTful API (even if most of comments we received are very positive and enthusiastic regarding how it's now possible to do complex operations in a friendly way, from different technologies, ...).
But I hope others we give a chance to discover how this new approach can be benefic in a world moving to Could and Mobility based applications.
Anthony -
Restful API add role not working - receve 202 accepted but not VM was created
Hi.
I am using the Windows azure restful api to add a new role to my vm deployment.
I have already added a cloud service and a deployment, I can list the deployments fine with the https://msdn.microsoft.com/en-us/library/azure/ee460804.aspx and is all OK , but when I want to add a new VM to this deployment and I call the api using https://msdn.microsoft.com/en-us/library/azure/jj157186.aspx
I get a 202 Accepted, but nothing happens, no VM was created , I dont know what I am missing .
This is the XML that I am sending together with the add role api
<PersistentVMRole xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<RoleName>vm-azure-lti3</RoleName>
<RoleType>PersistentVMRole</RoleType>
<ConfigurationSets>
<ConfigurationSet i:type="LinuxProvisioningConfigurationSet">
<ConfigurationSetType>LinuxProvisioningConfiguration</ConfigurationSetType>
<HostName>vm-linux-3</HostName>
<UserName>xxx</UserName>
<UserPassword>xxx</UserPassword>
</ConfigurationSet>
</ConfigurationSets>
<OSVirtualHardDisk>
<MediaLink>https://xxxx.blob.core.windows.net/vhds/communityimages2.vhd</MediaLink>
<SourceImageName>xxxx</SourceImageName>
<OS>Linux</OS>
</OSVirtualHardDisk>
</PersistentVMRole>
Hope someone can give me some litght into this as I am kind of lost now.
thanksHi Victor,
For called the REST API, I suggest you can use
Fiddler to catch and monitor your error message. If you got 404 error, it is possible that your authentication has something wrong. I suggest you can try to use fiddler to troubleshooting.
Any results, please feel free to let me know.
Regards,
Will
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Rest api to list all azure subscriptions under a particular azure account
Hi Buddy's,
Currently I am looking for the azure REST api to list all the subscriptions in a account.
We have the azure powershell commandlet "Get-AzureSubscription" which will give all the susbcriptions in the account , When it is executed with out any parameters.
Also we have the REST api https://management.core.windows.net/<subscription-id>, which will gives us the particular susbcription details.
So similarly let me know if any REST api to list down all the susbcriptions in a account.
Any help is greatly appreciated guys.
Thanks in advace,
-RakeshHi Rakesh,
You could try to use list subscription method to get the subscriptions. Please see this page (http://msdn.microsoft.com/en-us/library/azure/dn775050.aspx ).
RESR API URL:
https://management.core.windows.net/subscriptions
Hope this helps.
Will
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Hi, I'm looking for information about Restful API for PRSM--AsaCX. Regarding the Cisco documentation PRSM is built using REST API so anyone could create a custom management app for ASA CX, but I cannot find any information about this. I've looking at Cisco Developer community, Cisco forums, Internet....without success.
Some of you has any information about it??.
Thank you in advance
SamuelTo answer my own question. Just install from a ftp server with CLI...
-
Hi All,
We are trying to access the Create Deployment method stated below
http://msdn.microsoft.com/en-us/library/windowsazure/ee460813
We have uploaded the Package in the blob and browsing the configuration file. We have checked trying to upload manually the package and config file in Azure portal and its working
fine.
Below is the code we have written for creating deployment where "AzureEcoystemCloudService" is our cloud service name where we want to deploy our package. I have also highlighted the XML creation
part.
byte[] bytes =
new byte[fupldConfig.PostedFile.ContentLength + 1];
fupldConfig.PostedFile.InputStream.Read(bytes, 0, bytes.Length);
string a = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
string base64ConfigurationFile = a.ToBase64();
X509Certificate2 certificate =
CertificateUtility.GetStoreCertificate(ConfigurationManager.AppSettings["thumbprint"].ToString());
HostedService.CreateNewDeployment(certificate,
ConfigurationManager.AppSettings["SubscriptionId"].ToString(),
"2012-03-01", "AzureEcoystemCloudService", Infosys.AzureEcosystem.Entities.Enums.DeploymentSlot.staging,
"AzureEcoystemDeployment",
"http://shubhendustorage.blob.core.windows.net/shubhendustorage/Infosys.AzureEcoystem.Web.cspkg",
"AzureEcoystemDeployment", base64ConfigurationFile,
true, false);
<summary>
/// </summary>
/// <param name="certificate"></param>
/// <param name="subscriptionId"></param>
/// <param name="version"></param>
/// <param name="serviceName"></param>
/// <param name="deploymentSlot"></param>
/// <param name="name"></param>
/// <param name="packageUrl"></param>
/// <param name="label"></param>
/// <param name="base64Configuration"></param>
/// <param name="startDeployment"></param>
/// <param name="treatWarningsAsError"></param>
public static
void CreateNewDeployment(X509Certificate2 certificate,
string subscriptionId,
string version, string serviceName, Infosys.AzureEcosystem.Entities.Enums.DeploymentSlot deploymentSlot,
string name, string packageUrl,
string label, string base64Configuration,
bool startDeployment, bool treatWarningsAsError)
Uri uri = new
Uri(String.Format(Constants.CreateDeploymentUrlTemplate, subscriptionId, serviceName, deploymentSlot.ToString()));
XNamespace wa = Constants.xmlNamespace;
XDocument requestBody =
new XDocument();
String base64ConfigurationFile = base64Configuration;
String base64Label = label.ToBase64();
XElement xName = new
XElement(wa + "Name", name);
XElement xPackageUrl =
new XElement(wa +
"PackageUrl", packageUrl);
XElement xLabel = new
XElement(wa + "Label", base64Label);
XElement xConfiguration =
new XElement(wa +
"Configuration", base64ConfigurationFile);
XElement xStartDeployment =
new XElement(wa +
"StartDeployment", startDeployment.ToString().ToLower());
XElement xTreatWarningsAsError =
new XElement(wa +
"TreatWarningsAsError", treatWarningsAsError.ToString().ToLower());
XElement createDeployment =
new XElement(wa +
"CreateDeployment");
createDeployment.Add(xName);
createDeployment.Add(xPackageUrl);
createDeployment.Add(xLabel);
createDeployment.Add(xConfiguration);
createDeployment.Add(xStartDeployment);
createDeployment.Add(xTreatWarningsAsError);
requestBody.Add(createDeployment);
requestBody.Declaration =
new XDeclaration("1.0",
"UTF-8", "no");
XDocument responseBody;
RestApiUtility.InvokeRequest(
uri, Infosys.AzureEcosystem.Entities.Enums.RequestMethod.POST.ToString(),
HttpStatusCode.Accepted, requestBody, certificate, version,
out responseBody);
<summary>
/// A helper function to invoke a Service Management REST API operation.
/// Throws an ApplicationException on unexpected status code results.
/// </summary>
/// <param name="uri">The URI of the operation to invoke using a web request.</param>
/// <param name="method">The method of the web request, GET, PUT, POST, or DELETE.</param>
/// <param name="expectedCode">The expected status code.</param>
/// <param name="requestBody">The XML body to send with the web request. Use null to send no request body.</param>
/// <param name="responseBody">The XML body returned by the request, if any.</param>
/// <returns>The requestId returned by the operation.</returns>
public static
string InvokeRequest(
Uri uri,
string method,
HttpStatusCode expectedCode,
XDocument requestBody,
X509Certificate2 certificate,
string version,
out XDocument responseBody)
responseBody =
null;
string requestId = String.Empty;
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
request.Method = method;
request.Headers.Add("x-ms-Version", version);
request.ClientCertificates.Add(certificate);
request.ContentType =
"application/xml";
if (requestBody != null)
using (Stream requestStream = request.GetRequestStream())
using (StreamWriter streamWriter =
new StreamWriter(
requestStream, System.Text.UTF8Encoding.UTF8))
requestBody.Save(streamWriter,
SaveOptions.DisableFormatting);
HttpWebResponse response;
HttpStatusCode statusCode =
HttpStatusCode.Unused;
try
response = (HttpWebResponse)request.GetResponse();
catch (WebException ex)
// GetResponse throws a WebException for 4XX and 5XX status codes
response = (HttpWebResponse)ex.Response;
try
statusCode = response.StatusCode;
if (response.ContentLength > 0)
using (XmlReader reader =
XmlReader.Create(response.GetResponseStream()))
responseBody =
XDocument.Load(reader);
if (response.Headers !=
null)
requestId = response.Headers["x-ms-request-id"];
finally
response.Close();
if (!statusCode.Equals(expectedCode))
throw new
ApplicationException(string.Format(
"Call to {0} returned an error:{1}Status Code: {2} ({3}):{1}{4}",
uri.ToString(),
Environment.NewLine,
(int)statusCode,
statusCode,
responseBody.ToString(SaveOptions.OmitDuplicateNamespaces)));
return requestId;
But every time we are getting the below error from the line
response = (HttpWebResponse)request.GetResponse();
<Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Code>BadRequest</Code>
<Message>The specified configuration settings for Settings are invalid. Verify that the service configuration file is a valid XML file, and that role instance counts are specified as positive integers.</Message>
</Error>
Any help is appreciated.
Thanks,
ShubhenduPlease find the request XML I have found it in debug mode
<CreateDeployment xmlns="http://schemas.microsoft.com/windowsazure">
<Name>742d0a5e-2a5d-4bd0-b4ac-dc9fa0d69610</Name>
<PackageUrl>http://shubhendustorage.blob.core.windows.net/shubhendustorage/WindowsAzure1.cspkg</PackageUrl>
<Label>QXp1cmVFY295c3RlbURlcGxveW1lbnQ=</Label>
<Configuration>77u/PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0NCiAgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KDQogIFRoaXMgZmlsZSB3YXMgZ2VuZXJhdGVkIGJ5IGEgdG9vbCBmcm9tIHRoZSBwcm9qZWN0IGZpbGU6IFNlcnZpY2VDb25maWd1cmF0aW9uLkNsb3VkLmNzY2ZnDQoNCiAgQ2hhbmdlcyB0byB0aGlzIGZpbGUgbWF5IGNhdXNlIGluY29ycmVjdCBiZWhhdmlvciBhbmQgd2lsbCBiZSBsb3N0IGlmIHRoZSBmaWxlIGlzIHJlZ2VuZXJhdGVkLg0KDQogICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCi0tPg0KPFNlcnZpY2VDb25maWd1cmF0aW9uIHNlcnZpY2VOYW1lPSJXaW5kb3dzQXp1cmUxIiB4bWxucz0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9TZXJ2aWNlSG9zdGluZy8yMDA4LzEwL1NlcnZpY2VDb25maWd1cmF0aW9uIiBvc0ZhbWlseT0iMSIgb3NWZXJzaW9uPSIqIiBzY2hlbWFWZXJzaW9uPSIyMDEyLTA1LjEuNyI+DQogIDxSb2xlIG5hbWU9IldlYlJvbGUxIj4NCiAgICA8SW5zdGFuY2VzIGNvdW50PSIyIiAvPg0KICAgIDxDb25maWd1cmF0aW9uU2V0dGluZ3M+DQogICAgICA8U2V0dGluZyBuYW1lPSJNaWNyb3NvZnQuV2luZG93c0F6dXJlLlBsdWdpbnMuRGlhZ25vc3RpY3MuQ29ubmVjdGlvblN0cmluZyIgdmFsdWU9IkRlZmF1bHRFbmRwb2ludHNQcm90b2NvbD1odHRwcztBY2NvdW50TmFtZT1zaHViaGVuZHVzdG9yYWdlO0FjY291bnRLZXk9WHIzZ3o2aUxFSkdMRHJBd1dTV3VIaUt3UklXbkFrYWo0MkFEcU5saGRKTTJwUnhnSzl4TWZEcTQ1ZHI3aDJXWUYvYUxObENnZ0FiZnhONWVBZ2lTWGc9PSIgLz4NCiAgICA8L0NvbmZpZ3VyYXRpb25TZXR0aW5ncz4NCiAgPC9Sb2xlPg0KPC9TZXJ2aWNlQ29uZmlndXJhdGlvbj4=</Configuration>
<StartDeployment>true</StartDeployment>
<TreatWarningsAsError>false</TreatWarningsAsError>
</CreateDeployment>
Shubhendu G -
Streaming basics - reading large file from RESTful API
Hey all -
My command of PowerShell is pretty rudimentary, though I have written a number of scripts. In a recent example, I was trying to redirect the output of my firm's RESTful API - a small .txt file - into a file, using | out-file <path and
file>. THat worked
just fine. However, when I tried to do this with a docx or pdf file, the result was that I ended up with a small file that was
unopenable.
I gather what I need to do is stream the content to a file, but I can't quite see how that is done in Powershell. The files might be
many MB in size and take upwards of 30 seconds to transfer.
Any basic guidance on how to approach this would be appreciated. Thanks -
Paul
PaulOh so close!
I'm getting hung up on how to create and pass the session object itself.
My first command,
Invoke-RestMethod -Uri
<apiKey>9588060291......</apiKey><email>...</email><password>...</password><endOtherSessions>T</endOtherSessions></createSession">https://test.lofco.com/v1/ILCGLServices/session?method=CREATE"&"client=DEV-TEST"&"xml=<createSession><apiKey>9588060291......</apiKey><email>...</email><password>...</password><endOtherSessions>T</endOtherSessions></createSession>
-SessionVariable s -Outfile 'c:\LofCo\Demos\API Code Samples\XML\Output\createsession_response.xml'
returns successfully; I can see in the output file the session ID. I was hoping this was captured in the variable s via the -SessionVariable approach, but when I run the second command:
Invoke-RestMethod -Uri
<acceptSplash>T</acceptSplash></workspaceEntryRequest">https://test.lofco.com/services/workspaces/entry?client=DEV-TEST"&"workspaceId=226691"&"method=CREATE"&"xml=<workspaceEntryRequest><acceptSplash>T</acceptSplash></workspaceEntryRequest>
-WebSession $s -Method Post -Outfile 'C:\LofCo\Demos\API Code Samples\XML\Output\enterexchange_response.xml'
I get a 403 error indicating the session has expired or is otherwise invalid. I'm clearly confused as to how to capture this session and pass it along...
Any pointers on that piece? And thanks for your previous assistance.
Paul
Paul -
Flex: How to send Microphone Stream Audio data to a Rest API
Hi,
I needed to capture audio via a microphone and then sent ths instantanesouly to a REST API for processing. I do not want to use a media server.
So is it possible to send instataenous audio stream data to my custom servers.
Thanks,
Karanwell i tried this once for one of my scripts and the final conclusion is its not possible to combine two streams into 1.....how would you time/encode the two voices......there is no know solution to this in flash. If you continue on despite me and find a solution please post it so we can explain to rest of world.
-
Enabling Authentication on REST API
How is authentication (basic, certificate) enabled on an APIMGMT REST API?
In the portal there is client sample code for various languages including C# that includes code to add authentication headers. However, this code is commented out.
Basic Authorization Sample
client.DefaultRequestHeaders.Authorization
=
new AuthenticationHeaderValue("basic", Convert.ToBase64String(Encoding.UTF8.GetBytes("{username}:{password}")));
How is basic authentication enabled so that this code can be uncommented?
Frankhi Frank,
Base on my experience, you need enable the basic authentication in this page:
Then you can uncomment this code and input the username and pwasword. Please try it.
Any concerns, please let me know.
Regards,
Will
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.
Maybe you are looking for
-
I have trouble seeing the small icons for the program functions in this tutorial.
Hello, I have my assets from an older site, and want to start a site desktop site in muse. Is there a program ( maybe a book ) that can walk me through this step by step, instead of the Katie's Cafe demo / tutorial? The problem with the tutorial is i
-
Suspens account automatic clearing
Hello! I need to run an automatic clearing for a bank suspens account but my issue is that the payment document (from F110) and the bank transfer doesnt have fields in common. Asking the bank to change the assignment or text field is not an option fo
-
hi experts ,in my case on of the process chain turns into red color ,due to invalid characters and showing the error that invalid characters ,so at that time ,i made corrections form the error stack and executes the error dtp,the load successfully l
-
Missing file content in new iTunes
I downloaded the new iTunes on my Windows 7. Many of my music files now only have the title of the song. The content, including album, artist, genre, etc is still with the file in Windows Explorer but not with the song on iTunes. Because of this n
-
Configuration Managment Pack for Non Oracle Systems (new)
Hi , There is a pack called "Configuration Management" for the database. This pack manage hardware , software , updates, patches, etc for host that have installed any Oracle Software. Now, in EM Release 2 there is a new pack "Configuration Managment