I'm trying to use the REST API for IIS Media Services to create a Live Publishing point programatically. For this, I'm sending a POST call to this URL:
http://127.0.0.1/services/smoothstreaming/publishingpoints.isml/settings
I've included two custom headers to the request:
Content-Type: application/atom+xml
Slug: /test.isml
And this is the body of the request:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<id>http://127.0.0.1/test.isml/settings</id>
<title>Test</title>
<updated>2012-07-12T19:13:25Z</updated>
<content type="application/xml">
<SmoothStreaming xmlns="http://schemas.microsoft.com/iis/media/2011/03/streaming/management">
<Settings>
<Title>Test</Title>
<SourceType>Push</SourceType>
<AutoStart>false</AutoStart>
<AutoRestartOnEncoderReconnect>false</AutoRestartOnEncoderReconnect>
<LookAheadChunks>2</LookAheadChunks>
<Archive enabled="false">
<Path useEventIdOnPath="false" />
</Archive>
<ClientConnections enabled="true">
<ClientManifestVersion>2.0</ClientManifestVersion>
</ClientConnections>
<ServerConnections enabled="false">
<SendEndOfStreamOnStop>false</SendEndOfStreamOnStop>
</ServerConnections>
</Settings>
</SmoothStreaming>
</content>
</entry>
IIS is giving me a 405/Bad Request error with this body:
<?xml version="1.0" encoding="UTF-8"?>
<SmoothStreaming xmlns="http://schemas.microsoft.com/iis/media/2011/03/streaming/management">
<Error>
<ErrorCode>0x80880026</ErrorCode>
<ErrorMessage>The resource contains one or more elements that contain invalid data. For information about valid resource representations, please see the documentation for the supported schemas.</ErrorMessage>
</Error>
</SmoothStreaming>
Anyone knows what I'm doing wrong here?
Ommiting the "Archive" and "ServerConnections" nodes fixed it. Not sure it there's anything wrong in them, or if they're only supposed to be included when enabled=true.
Related
I have to develop a Camel REST route with path-based routing.
The scenario is as follows: we have a business partner which provided a REST web service for displaying documents. The REST web service is deployed on 3 different servers, depending on the geographic location.
So we basically have 3 server like these:
http://north.acme.com/flowdocv2/rest/repository/attachment/{id}/findById
http://center.acme.com/flowdocv2/rest/repository/attachment/{id}/findById
http://south.acme.com/flowdocv2/rest/repository/attachment/{id}/findById
My aim is to develop a single Camel route to map these server, accepting the name of the server in the path. Something like this:
http://my.camel.com/center/repository/attachment/{id}/findById
http://my.camel.com/north/repository/attachment/{id}/findById
http://my.camel.com/south/repository/attachment/{id}/findById
My (simplified and not working) blueprint.xml:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<cm:property-placeholder persistent-id="my.config.file"/>
<reference id="sharedNettyHttpServer" interface="org.apache.camel.component.netty4.http.NettySharedHttpServer"/>
<camelContext id="my_context" xmlns="http://camel.apache.org/schema/blueprint">
<restConfiguration component="netty4-http">
<endpointProperty key="nettySharedHttpServer" value="#sharedNettyHttpServer"/>
</restConfiguration>
<rest path="/center/repository">
<get uri="/attachment/{attachmentId}/findById">
<route streamCache="true" trace="true">
<to uri="http://center.acme.com/flowdocv2/rest?bridgeEndpoint=true"/>
</route>
</get>
</rest>
<rest path="/north/repository">
<get uri="/attachment/{attachmentId}/findById">
<route streamCache="true" trace="true">
<to uri="http://north.acme.com/flowdocv2/rest?bridgeEndpoint=true"/>
</route>
</get>
</rest>
</camelContext>
</blueprint>
The problem is that I don't know how to remove /center, /north or /south from the path, so the header is forwared to the destination service, which doesn't know how to deal with it.
Invoking:
http://my.camel.com/center/repository/attachment/{id}/findById
results in the following URL being invoked on the destination server:
http://center.acme.com/flowdocv2/rest/center/repository/attachment/{id}/findById
How to get rid of center? I don't want to deploy 3 camel routes on different ports.
Thank you
I think it is actually a bit easier. As long as you do not hang onto netty and you are using Camel 2.11+ you can use camel-urlrewrite
Basically, you define a single rewrite rule in a configuration and add this to your route bundle.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
"http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite>
<rule>
<name>Generic Proxy</name>
<note>
This rule completely rewrites the url to call.
Basically, in Camel's "to", you could write whatever you want
</note>
<from>^/(.*?)/(.*)</from>
<to>http://$1.acme.com/flowdocv2/rest/$2</to>
</rule>
</urlrewrite>
Now, you can utilize a rather simple route:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0" xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<bean id="myRewrite" class="org.apache.camel.component.urlrewrite.HttpUrlRewrite">
<property name="configFile" value="class/path/to/proxyrewrite.xml" />
</bean>
<camelContext id="my_context" xmlns="http://camel.apache.org/schema/blueprint">
<route id="proxyRoute">
<from uri="jetty:http://localhost:9090/proxy" />
<to uri="jetty:http://somewhere/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite" />
</route>
</camelContext>
</blueprint>
However, netty is not supported, so I chose the next best thing.
When you call http://localhost:9090/proxy/north/foo, the rewrite will actually change the url to call to http://north.acme.com/flowdoc2/rest/foo.
There are a few caveats with this. First, you have to use one of the supported components for UrlRewrite. Second, it seems that you have to have the rewrite config file in you classpath - so no blueprint-only route. Third: I did not test it, but I think you get the gist. I make this a community wiki answer, so that others, more capable than me, can expand on this answer.
According to the Accounting API docs named lists items are soft deleted, so it is possible to reactivate them with a sparse update where Active is set to true. This is working fine for Term, Account, PaymentMethod, and Department.
However we ran into issues when trying to sparse update Class and TaxCode. Here are the request/response we got in each case:
<?xml version="1.0" encoding="UTF-8"?>
<Class xmlns="http://schema.intuit.com/finance/v3" sparse="true">
<Id>5000000000000020362</Id>
<Name>Consultancy (deleted)</Name>
<SyncToken>1</SyncToken>
<Active>true</Active>
</Class>
Response from request to sparse update to reactivate class:
<?xml version="1.0" encoding="UTF-8"?>
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2016-12-29T10:36:51.732-08:00">
<Fault type="ValidationFault">
<Error code="6000" element="">
<Message>A business validation error has occurred while processing your request</Message>
<Detail>Business Validation Error: You cannot modify a list element that has been deleted.</Detail>
</Error>
</Fault>
</IntuitResponse>
Request to activate a tax code
<?xml version="1.0" encoding="UTF-8"?>
<TaxCode xmlns="http://schema.intuit.com/finance/v3" sparse="true">
<Id>4</Id>
<Name>California - Inactive</Name>
<SyncToken>1</SyncToken>
<Active>true</Active>
</TaxCode>
Response from request to sparse update to reactivate tax code:
<?xml version="1.0" encoding="UTF-8"?>
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2016-12-30T14:20:24.614-08:00">
<Fault type="ValidationFault">
<Error code="500" element="Operation">
<Message>Unsupported Operation</Message>
<Detail>Operation Update is not supported.</Detail>
</Error>
</Fault>
</IntuitResponse>
Any help would be much appreciated.
Thanks,
Fernando
I've followed a tutorial online on how to create a custom REST API endpoint for Magento 1.9.2. However, after completing the oauth process and getting a secret and key I always get a 404 trying to call the endpoint.
I think my problem is coming from the api.xml file as I don't quite understand the values that can be used for the various options. The file is below:
<config>
<api2>
<resource_groups>
<categories translate="title" module="EG_Categories">
<title>Categories API</title>
<sort_order>10</sort_order>
</categories>
</resource_groups>
<resources>
<categories translate="title" module="EG_Categories">
<group>categories</group>
<model>categories/api2_categoriesapi</model>
<title>Category API</title>
<sort_order>10</sort_order>
<privileges>
<admin>
<create>1</create>
<retrieve>1</retrieve>
</admin>
<guest>
<retrieve>1</retrieve>
</guest>
</privileges>
<attributes>
<name>Category Name</name>
<parent>Parent ID</parent>
</attributes>
<routes>
<route>
<route>/categories/retrieve</route>
<action_type>collection</action_type>
</route>
</routes>
<versions>1</versions>
</categories>
</resources>
</api2>
</config>
In particular, I haven't been able to find out if collection is the correct value for the action type to activate the _retrieveCollection method in the class file.
I have one class file located at app/code/local/EG/Categories/Model/Api2/Categories.php.
Also in APi2 is /Categories/Rest/Admin/V1.php.
Any advice would be much appreciated.
I am trying to publish an application to Azure Service Fabric cluster. The moment I click publish from VS2015, I get those following errors:
"An error occurred reading the file xxx\publishprofiles\cloud.xml. There is an error in XML document (7, 6)"
"Object reference not set to an instance of an object"
This is the content of the Cloud.xml file:
<?xml version="1.0" encoding="utf-8"?>
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools">
<ClusterConnectionParameters ConnectionEndpoint=... />
<ApplicationParameterFile Path="xxx\ApplicationParameters\Cloud.xml" />
<UpgradeDeployment Mode="Monitored" Enabled="true">
<Parameters FailureAction="Rollback" Force="True" />
<Parameters UpgradeReplicaSetCheckTimeoutSec="1" Force="True" />
</UpgradeDeployment>
</PublishProfile>
It seems that I can have only one of the parameters (FailureAction OR UpgradeReplicaSetCheckTimeoutSec) for VS2015 to successfully load the file.
I wonder if anyone has some insights into this issue?
There can only be one Parameters element. Combine all your parameters into just one Parameters element.
Example:
<?xml version="1.0" encoding="utf-8"?>
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools">
<ClusterConnectionParameters ConnectionEndpoint=... />
<ApplicationParameterFile Path="xxx\ApplicationParameters\Cloud.xml" />
<UpgradeDeployment Mode="Monitored" Enabled="true">
<Parameters FailureAction="Rollback" Force="True" UpgradeReplicaSetCheckTimeoutSec="1" />
</UpgradeDeployment>
</PublishProfile>
I'm attempting to perform a batch update of google contacts per https://developers.google.com/google-apps/contacts/v3/#batch_operations_for_contacts, but I'm getting an "Invalid entry Id/Uri" error. I'm posting the following XML:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gContact="http://schemas.google.com/contact/2008" xmlns:gd="http://schemas.google.com/g/2005" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" gd:etag=""RHwzfzVSLyt7I2A9XRVREk4DQQw."">
<entry gd:etag=""Q34zcDVSLit7I2A9XRVTFkkOTwE."">
<id>http://www.google.com/m8/feeds/contacts/emiliano.heyns%40iris-advies.com/base/376125d892c1b5a</id>
<batch:id>delete-cornel.straver#han.nl</batch:id>
<batch:operation type="delete"/>
</entry>
</feed>
to which I'm getting this response:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gd="http://schemas.google.com/g/2005" xmlns:gContact="http://schemas.google.com/contact/2008">
<id>https://www.google.com/m8/feeds/contacts/emiliano.heyns%40iris-advies.com/full/batch/1432240618884</id>
<updated>2015-05-21T20:36:58.884Z</updated>
<title>Batch Feed</title>
<entry>
<id>http://www.google.com/m8/feeds/contacts/emiliano.heyns%40iris-advies.com/base/376125d892c1b5a</id>
<updated>2015-05-21T20:36:58.884Z</updated>
<title>Error</title>
<content>Invalid entry Id/Uri</content>
<batch:id>delete-cornel.straver#han.nl</batch:id>
<batch:status code="400" reason="Invalid entry Id/Uri"/>
<batch:operation type="delete"/>
</entry>
</feed>
I know the etags and the ID are correct as I've gotten them by requesting the contacts feed; it's the response from that which I'm modyfying into the query above.