i´m playing arround with the HIGHRISE API, and they understood the meaning of rest, its pretty cool and at some points gracefully forgivingly, but
has anybody any idea why the xml i PUT is not accepted ?
here is some relevant logging :
2014-02-23 00:00:04] app.INFO: Updating:Person:Highrise-API = people/11834527375.xml [] []
[2014-02-23 00:00:04] app.INFO: request body is :
<?xml version="1.0" encoding="UTF-8"?>
<person>
<first-name><![CDATA[Johnny]]></first-name>
<last-name><![CDATA[B. Good]]></last-name>
<visible-to><![CDATA[Everyone]]></visible-to>
<subject_datas type="array">
<subject_data>
<subject_field_id type="integer"><![CDATA[43212]]></subject_field_id>
<value><![CDATA[dsa328394OOKD323H]]></value>
</subject_data>
<subject_data>
<subject_field_id type="integer"><![CDATA[470259]]></subject_field_id>
<value><![CDATA[provider://w184071823/fmdks/2032]]></value>
</subject_data>
<subject_data>
<subject_field_id type="integer"><![CDATA[469130]]></subject_field_id>
<value><![CDATA[CORE]]></value>
</subject_data>
<subject_data>
<subject_field_id type="integer"><![CDATA[469132]]></subject_field_id>
<value><![CDATA[Way too cool]]></value>
</subject_data>
</subject_datas>
<contact-data>
<phone-numbers>
<phone-number type="array">
<number><![CDATA[081 6418273]]></number>
<location><![CDATA[Work]]></location>
</phone-number>
</phone-numbers>
<addresses type="array">
<address>
<city><![CDATA[New York City]]></city>
<country><![CDATA[US]]></country>
<state><![CDATA[New York]]></state>
<street><![CDATA[Siplingerstreet 11]]></street>
<zip><![CDATA[87527]]></zip>
<location><![CDATA[Work]]></location>
</address>
</addresses>
</contact-data>
</person>
[] []
[2014-02-23 00:00:04] app.INFO: request set [] []
[2014-02-23 00:00:04] app.ERROR: Guzzle/3.8.1 curl/7.28.1 PHP/5.4.10 - [2014-02-22T23:00:04+00:00] "PUT /people/11834527375.xml HTTP/1.1" 422 103 [] []
[2014-02-23 00:00:04] app.INFO: Caught client-error-exception in HighriseService updatePerson(): exception 'Guzzle\Http\Exception\ClientErrorResponseException' with message 'Client error response
[status code] 422
[reason phrase] Unprocessable Entity
i dont see the error :/
I´m very sure the subject_field_id´s are correct and those custom fields are set
Posting e.g saving that xml works, i saw from the response that are fields were set,
only thing i can guess is, that i´m trying to PUT a version where nothing has changed,
is that the problem ?
because my code only checks if that person exists at all and if so update it instead of creating
You should get back some XML in the body of the response. It should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<errors>
<error>Phone number '555-555-5555' has already been taken</error>
</errors>
If you include the id for the existing phone number in your PUT request, then we know that you want to update the existing address, rather than adding a new one: https://github.com/basecamp/highrise-api/blob/master/sections/people.md#update-person
Contact data and Subject data that include an id will be updated, data that doesn’t will be assumed to be new and created from scratch. To remove a piece of data, prefix its id with a minus sign (e.g. -1).
Related
I am implementing a GET request which needs to interact with an ERP and extract employee details .
Now the interaction with ERP is not using HTTP so it does not return status codes such as 400 etc
Any error if present is returned in the XML payload response .
Example:
<?xml version="1.0" encoding="utf8" ?>
<Output>
<Error>
<Status>0</Status>
<Details>No errors</Details>
</Error>
</Output>
So I have implemented it this way - where after calling ERP and receiving response I check if response contains any error ( errorCode = 0 means an error otherwise all good )
If not an error normal processing , if an error I simply set the http status to 400 and populate response with error details.
Question:
In the error flow I am NOT throwing any exception / error and simply returning a response with 400 response status and error details .
My gut feel is in this case there is no need to Raise error ( throw ) and then again catch it in error handler.
I thought it is unnecessary in this case but was looking for some feedback ?
Note - the exception handler below is meant to catch errors such as ERP is down / unavailable etc
Note - as this is more a design / approach question , am only pasting screen print of the flow and not the actual code
Please do share your feedback and suggestions
There is no mandate to use Mule Error handling to return an HTTP status, if that's your question.
Note that Mule 4 uses error handling, not exception handling, though it looks similar.
Unrelated, it is strange that you are using HTTP status 400 for a server error, when 400 is meant for bad client request. You may want to use a more proper status.
i fetch data from SAP and set the payload.
while setting the payload getting below error.
13:30:52.705 10/03/2017 Worker-0 [apl-sfa-batch-interface-v44].sfdc-sap-bw-interfaceFlow.stage1.57 ERROR
********************************************************************************
Message : Execution of the expression "dw('payload.ZCS_SR.tables.ET_DATA.*row')" failed. (org.mule.api.expression.ExpressionRuntimeException).
Payload : <?xml version='1.0' encoding='UTF-8'?>
<ZCS_SR>
<export>
<EV_FAILURE></EV_FAILURE>
<EV_SUCCESS>The SR Details is successfully returned from BW system</EV_SUCCESS>
</export>
<tables>
<ET_DATA>
<row id="0">
<CRM_OHGUID>123</CRM_OHGUID>
<RECORDMODE>N</RECORDMODE>
<CRM_OBJ_ID>123</CRM_OBJ_ID>
So it could fail for many reasons.
First guess is suspicious
dw('payload.ZCS_SR.tables.ET_DATA.*row')
It means that you pass the string "payload.ZCS_SR.tables.ET_DATA.*row" to unknown function dw().
So, actual transformation is not involved.
Usually it looks like
{
arrayOfRows: payload.ZCS_SR.tables.ET_DATA.*row
}
Second guess would be that XML is not ended. There is no end tag even for row itself.
Guesses could continue endlessly.
You had provided too limited information.
It is impossible to answer based on information you had provided.
I have a container (music show) with 19 tracks in it and 1 item for recommendations section for this show. So totaly there are 20 items. But if I am adding this show to playlist, only tracks will be processed and playlsit will contain 19 tracks. Sonos controller is working fine with it, but Test Suite fails with checking total items after adding show to playlist with message
FAIL The seed playlist and newly created playlist should have the same
quantity of items inside. (expected 19 != actual 20)
As the result Test Suite fails with 1 error. Is it O.K. to send test suite report with such fail? Or you will deny new service with such fail?
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://www.sonos.com/Services/1.1">
<SOAP-ENV:Body>
<ns1:getMetadataResponse>
<ns1:getMetadataResult>
<ns1:index>0</ns1:index>
<ns1:count>20</ns1:count>
<ns1:total>20</ns1:total>
<ns1:mediaCollection>
<ns1:id>CONTAINER:RECOMMENDATIONS:594</ns1:id>
<ns1:itemType>collection</ns1:itemType>
<ns1:displayType>grid</ns1:displayType>
<ns1:title>Recommendations</ns1:title>
<ns1:canPlay>false</ns1:canPlay>
<ns1:canAddToFavorites>false</ns1:canAddToFavorites>
</ns1:mediaCollection>
<ns1:mediaMetadata>
<ns1:id>TRACK:11422:594</ns1:id>
<ns1:itemType>track</ns1:itemType>
<ns1:displayType>list</ns1:displayType>
<ns1:title>He Ain't Give You None</ns1:title>
<ns1:summary>The Radiators</ns1:summary>
<ns1:mimeType>audio/mp3</ns1:mimeType>
<ns1:trackMetadata>
<ns1:artist>The Radiators</ns1:artist>
<ns1:duration>531</ns1:duration>
<ns1:rating>0</ns1:rating>
<ns1:canPlay>true</ns1:canPlay>
<ns1:canSkip>true</ns1:canSkip>
</ns1:trackMetadata>
</ns1:mediaMetadata>
<ns1:mediaMetadata>
<ns1:id>TRACK:58012:594</ns1:id>
<ns1:itemType>track</ns1:itemType>
<ns1:displayType>list</ns1:displayType>
<ns1:title>Alimony</ns1:title>
<ns1:summary>The Radiators</ns1:summary>
<ns1:mimeType>audio/mp3</ns1:mimeType>
<ns1:trackMetadata>
<ns1:artist>The Radiators</ns1:artist>
<ns1:duration>632</ns1:duration>
<ns1:rating>0</ns1:rating>
<ns1:canPlay>true</ns1:canPlay>
<ns1:canSkip>true</ns1:canSkip>
</ns1:trackMetadata>
</ns1:mediaMetadata>
[MORE ITEMS HERE]
</ns1:getMetadataResult>
</ns1:getMetadataResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I am taking some liberties in answering your question since it seems to be directed at Sonos, so apologies in advance. It is very unlikely that your service will be rejected for a bug that happens to be inside Sonos test suite.
So my two cents, go for it and submit your service.
I believe that the issue here is that a playlist is defined as container specifically full of track elements (http://musicpartners.sonos.com/node/286) and your playlist contains a collection. This is why this is failing to generate the correct count in the test.
Using the JavaScript SDK, I am trying to search for all tracks in a given genre from a given date going forward (using the 'created_at[from]' /tracks filter).
My JavaScript for this is:
SC.get('/tracks', { genres: 'metal', created_at: {from: '2014-02-26 00:00:01'} }, function(tracks) {
console.log(tracks);
});
The request URL resolves as:
http://api.soundcloud.com/tracks?genres=metal&created_at[from]=2014-02-26%2000%3A00%3A01&client_id=MY_ID
and I get a 503. (I omitted posting my client_id here intentionally)
What am I doing wrong here?
Looks like they changed the filter or its a bug or they are working on it:
When i call:
http://api.soundcloud.com/tracks?limit=1&genres=metal&client_id=b45b1aa10f1ac2941910a7f0d10f8e28&created_at=2010-10-10
I am getting:
invalid filter.created_at=2010-10-10;
valid values are: last_year, last_two_weeks, last_week, last_day, last_hour
Then, when i call for last hour:
http://api.soundcloud.com/tracks?limit=1&genres=metal&client_id=b45b1aa10f1ac2941910a7f0d10f8e28&created_at=last_hour
I am getting a: 503 - Service Unavailable
When i change it to last_year, it works as expected,
and i get following xml (or json):
<tracks next-href="http://api.soundcloud.com/tracks?client_id=b45b1aa10f1ac2941910a7f0d10f8e28&created_at=last_year&genres=metal&limit=1&offset=1" type="array">
<track>
<kind>track</kind>
<id type="integer">103909859</id>
<created-at type="datetime">2013-08-04T01:30:44Z</created-at>
<user-id type="integer">29394873</user-id>
<duration type="integer">248917</duration>
<commentable type="boolean">true</commentable>
<state>finished</state>
<original-content-size type="integer">4696472</original-content-size>
<sharing>public</sharing>
<tag-list>
exotoxis metal femalevocals rock shredding army god double bass
</tag-list>
<permalink>army-of-god</permalink>
<streamable type="boolean">true</streamable>
<embeddable-by>all</embeddable-by>
<downloadable type="boolean">false</downloadable>
<purchase-url nil="true"/>
<label-id nil="true"/>
<purchase-title nil="true"/>
<genre>Metal</genre>
<title>Army Of God</title>
<description>
For more Information plea
EDIT:
I'd say you are right and SC Team should give an answer on that.
My connection to QB online is working fine. It also works for add customers to QB online.
When i am passing checks through it gives Bad request error.
below is my qbxml.
string post = #"<?xml version=""1.0"" encoding=""utf-8"" ?>
<?qbxml version=""10.0""?>
<QBXML>
<SignonMsgsRq>
<SignonDesktopRq>
<ClientDateTime>%%CLIENT_DATE_TIME%%</ClientDateTime>
<ApplicationLogin>%%AppLogin%%</ApplicationLogin>
<ConnectionTicket>%%ConnTicket%%</ConnectionTicket>
<Language>English</Language>
<AppID>%%AppID%%</AppID>
<AppVer>1</AppVer>
</SignonDesktopRq>
</SignonMsgsRq>
<QBXMLMsgsRq onError=""continueOnError"">
<CheckAddRq>
<CheckAdd>
<AccountRef>
<ListID>1</ListID>
<FullName>Chase Checking</FullName>
</AccountRef>
<PayeeEntityRef>
<ListID>IDTYPE</ListID>
<FullName>Test Vendor</FullName>
</PayeeEntityRef>
<RefNumber>11</RefNumber>
<TxnDate>05/06/2012</TxnDate>
<Memo>My first Memo</Memo>
<Address>
<Addr1>Ahmedabad</Addr1>
<Addr2>Ahmedabad</Addr2>
<Addr3>Ahmedabad</Addr3>
<Addr4>Ahmedabad</Addr4>
<Addr5>Ahmedabad</Addr5>
<City>Ahmedabad</City>
<State>Gujarat</State>
<PostalCode>360015</PostalCode>
<Country>India</Country>
<Note>Note</Note>
</Address>
<IsToBePrinted>N</IsToBePrinted>
<ExchangeRate></ExchangeRate>
<ExternalGUID></ExternalGUID>
<ApplyCheckToTxnAdd>
<TxnID>9054</TxnID>
<Amount>1000</Amount>
</ApplyCheckToTxnAdd>
<ExpenseLineAdd>
<AccountRef>
<ListID></ListID>
<FullName>PublisherPayment</FullName>
</AccountRef>
<Amount>100</Amount>
<Memo>Memo</Memo>
</ExpenseLineAdd>
</CheckAdd>
<IncludeRetElement>STRTYPE</IncludeRetElement>
</CheckAddRq>
</QBXMLMsgsRq>
</QBXML>";
Can anybody guide, please ?
As the qbxml version needs to be 6.0 (even though the IDN Unified On-Screen Reference shows 7.0)
I needed to include the onError="continueOnError" attribute.
Setting the WebRequestObject.ContentLength property is required.
Content Type needs to be "application/x-qbxml"
And finally I received many "The remote server returned an error: (400) Bad Request." exceptions which were not helpful at all but in the end I was able to trace them to something wrong with the xml. So if you get this exception look to your xml as the source of the problem.
So, finally i changed my xml as below.
string post = #"<?xml version=""1.0"" encoding=""UTF-8""?>
<?qbxml version=""6.0""?>
<QBXML>
<SignonMsgsRq>
<SignonDesktopRq>
<ClientDateTime>%%CLIENT_DATE_TIME%%</ClientDateTime>
<ApplicationLogin>%%AppLogin%%</ApplicationLogin>
<ConnectionTicket>%%ConnTicket%%</ConnectionTicket>
<Language>English</Language>
<AppID>%%AppID%%</AppID>
<AppVer>1</AppVer>
</SignonDesktopRq>
</SignonMsgsRq>
<QBXMLMsgsRq onError=""stopOnError"">
<CheckAddRq requestID=""1"">
<CheckAdd>
<AccountRef>
<FullName>Checking</FullName>
</AccountRef>
<PayeeEntityRef>
<FullName>Departures Magazine</FullName>
</PayeeEntityRef>
<RefNumber>9999</RefNumber>
<TxnDate>2012-06-06</TxnDate>
<Memo>Injury Claims Payment</Memo>
<Address>
<Addr1>Eli Manning</Addr1>
<Addr2>1234 S. Giant St</Addr2>
<City>New York</City>
<State>NY</State>
<PostalCode>40961</PostalCode>
</Address>
<IsToBePrinted>false</IsToBePrinted>
<ExpenseLineAdd>
<AccountRef>
<FullName>Publisher Payment</FullName>
</AccountRef>
<Amount>200.00</Amount>
</ExpenseLineAdd>
</CheckAdd>
</CheckAddRq>
</QBXMLMsgsRq>
</QBXML>";