Fetching data from estimates in zoho invoices - zoho

i'm trying to fetch data from estimates module in Zoho Invoices but it keep giving me error of invalid url passed, the url im using is:
https://invoice.zoho.com/api/GET/estimates/{$estimate_id}?authtoken={$auth}&organization_id={$org_id}
and the response im getting is:
<Response status="0">
<Code>5</Code>
<Message>
<![CDATA[ Invalid URL Passed ]]>
</Message>
</Response>
Can you please tell me what is wrong with it, or some other method to get the task done. Thankyou!

The URL you are trying to use is invalid.
The URL should be like
https://invoice.zoho.com/api/v3/estimates/$estimate_id?authtoken=$auth_token&organization_id=$org_id.
Here's the API documentation that would guide you.

Related

What does this Google API error message mean?

Imagine you call an API to get an in-app purchase details. It has 3 params: package name (de facto app ID), product ID and a purchase token.
You get the following response: HTTP 400 Invalid Value with JSON body like this:
[{'message': 'Invalid Value', 'domain': 'global', 'reason': 'invalid'}]
Is your package name invalid? Is your product ID invalid? Or is your purchase token invalid?
Hint: all of the values you passed are valid.
Question: what is wrong?
Answer: you're calling an incorrect API method. The purchase was not a product, it was a subscription.
I've wrote a ton of APIs myself and I would never ever return a HTTP 400 with such confusing output.
Google, you can do better.

Phone number obligatory on new contact entry

I want to send a POST request on Google Contacts API. It works well at the moment.
But I wonder why I get a 400 Bad Request Error if I don't specify a phone number.
<?xml version="1.0" encoding="UTF-8"?>
<errors xmlns="http://schemas.google.com/g/2005">
<error>
<domain>GData</domain>
<code>invalid</code>
<internalReason>Phone number must not be empty</internalReason>
</error>
</errors>
If someone knows if I can bypass it ?
Notice that when you add a contact on Google Contacts, there's not this restriction.
You're getting that error because it's stated in the docs that these extension elements need to be provided a rel attribute or a label attribute:
In the Contacts Data API, several elements are slightly more
restrictive than indicated in the documentation for the Contact kind.
In particular, a client must supply either a rel attribute or a label
attribute, but not both, for the following elements:
gd:email gd:im gd:organization gd:phoneNumber gd:postalAddress
In short, you really need to provide the phone number.

How to consume XML with more than one possible root element in Spring REST client

In my application I have to consume a service provided by a third party application. The response they provide is always 200 and they change the body based on whether data is available or not or error occurred, as given below
If data is there then
<products>
<product></product>
<product></product>
</products>
If data is empty then
<message> No record found </message>
If some validation failed then
<error>Invalid Id</error>
I am using RestTemplate.exchange to consume the service, my question is if there only single type of root element then we pass the respective class as ParameterizedTypeReference but here how to map the response and unmarshall it.
Use jaxb or jackson to unmarshall the xml.
The right thing to do here is to ask the third party to change their service response to have a root tag. The response object would then look something like this:
<response>
<products>
<product></product>
<product></product>
</products>
<message> No record found </message>
<error>Invalid Id</error>
</response>
With this, you will only need to be concerned about response object and you can check the presence of respective sub-tags.
Other option to make this work for you is to do the exchange by passing String.class as the type reference. Then you would need to do the check in your code to see if the string response returned is products or message or error

Plivo Speak doesn't work

I have created a really simple xml file for testing plivo:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Speak>Hello, Input your 4-digit pin number</Speak>
<GetDigits action="https://example.com/voice/plivo/renderVoiceCallDirective/wGather" method="POST">
<Speak>Enter your 4-digit pin number, followed by the hash key</Speak>
</GetDigits>
<Speak>Input not received. Thank you</Speak>
<Redirect>/voice/plivo/timeoutRedirect/xxx</Redirect>
</Response>
In theory, plivo will read the content of and gather the input digits
but it seems like the Speak and GetDigits doesn't work, because after getting this xml, plivo directly goes to the redirect url. The call will last several second and hangup. Any one know why this happens? Thanks
The XML is validated first before executing it. The URL given in "Redirect" tag is not a valid URL. So the XML fails the validation and the call hangs up.
Try using a valid URL in Redirect XML.

HttpWebRequest/Response throwing error "Not Found"

I am making an API call to a REST service. The REST service returns an XML string that contains a user token if the password submitted is correct, or an XML string with data if it isn't.
Here is an example if the password is incorrect:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<authenticationResponse>
<statusCode>403</statusCode>
<errors>
<error>
....
</error>
</errors>
<timestamp>2011-03-31 22:45:03 GMT</timestamp>
</authenticationResponse>
With this code below, it appears .NET is translating this to an actual error. I still want it to read the XML data and ignore any error:
RequestData requestData = (RequestData)result.AsyncState;
HttpWebResponse response =
(HttpWebResponse)requestData.Request.EndGetResponse(result);
How I can ignore the error but still create the stream to read the XML?
Catch WebException, check the exception status, read the response. See these questions for examples:
Catching a specific WebException (550)
WebException when reading a WebException's response stream
Your code isn't translating this into an actual error - a HTTP status code of 403 is "Forbidden".
HTTP "Not Found" has a HTTP status code of 404 so it looks like the HTTP endpoint you're requesting doesn't exist in the REST service.
Ok so I figured it out, there's a few parts here.
First off the API is generating that xml when the parameters passed don't meet whats expected. In this case, if the password is incorrect, it'll pass back the 403.
The error is an error, so the framework treats it as such, however the error contains a response anyways, you just have to get the response off the error. This is essentially the answer to the question. Have to catch it the error and snag the response off the error to read the data in the stream, which is what Mauricio was getting to.
Essentially, I guess all the answers here are correct, or pieces of it, just took a little digging to put it all together.
Thanks Guys.

Resources