HTML error message returned when expecting XML - intuit-partner-platform

We have a situation where we are expecting an error message in XML to be returned from Quickbooks online, however, we're getting the following message back from the API with a status code of 400.
<html>
<head>
<title>JBoss Web/2.1.12.GA-patch-03 - Error report</title>
<style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style>
</head>
<body>
<h1>HTTP Status 400 - message=No destination found for given partition key; errorCode=007001; statusCode=400</h1>
<HR size="1" noshade="noshade">
<p>
<b>type</b> Status report
</p>
<p>
<b>message</b> <u>message=No destination found for given partition key; errorCode=007001; statusCode=400</u>
</p>
<p>
<b>description</b> <u>The request sent by the client was syntactically incorrect (message=No destination found for given partition key; errorCode=007001; statusCode=400).</u>
</p>
<HR size="1" noshade="noshade">
<h3>JBoss Web/2.1.12.GA-patch-03</h3>
</body>
</html>
It seems like the client has an expired trial account. Should our code handle this type of error, or is this Intuit's problem because they're not returning an XML message?

If you make request without error and get this response, probably your account on Quickbooks doesn't exist.
I faced with this issue. When I go through oauth flow. I get correct oauth key & secret. But when I make api call, so get the same error. I discovered that my account (which I use for make API call) doesn't exist in Quickbooks. With other existing account it works fine.
Hope this help.

Related

Validating form with unpoly

I' trying to validate a form with unpoly. Here my HTML:
<div>
<label for="salesrepresentative-name">Name: </label><br/>
<input id="salesrepresentative-name" name="name" up-validate=".name-errors"/>
<span class="name-errors"></span>
</div>
And the error message what i get is:
Could not find failure target in response (tried [".name-errors", "body"])
Any ideas, what i'm doing wrong?
up-validate will submit the form and replace your current <span class="name-errors"> with the same span from the response.
The error message you received means that the form submission did not include a <span class="name-errors">. If even did not include a <body> tag (which Unpoly uses as a fallback when selectors are missing).
Try to submit the form without Unpoly and see if the response is what you're expecting.

SOAP message MUST NOT contain a Document Type Declaration(DTD) in wso2 ESB 4.9.0 when Calling an API

I try to call an identity server (for Reckon API), this will send back to me an HTML page which I should pass the username and password to it to authorise me but in WSO2 ESB the following message shows up:
SOAP message MUST NOT contain a Document Type Declaration(DTD)
I can see the html page details in the ESB log but.
Remaining input stream :[ </li> </ul> </div> </div> </div> </div> </div> <script id='modelJson' type='application/json'>{"loginUrl":"/login?signin=cdf07a3cb572cd62438b93ab5fa39b48","antiForgery":{"name":"idsrv.xsrf","value":"Fws6qKgkCal2HVkpciKAuvce-95kVOdD5W2gJUSYzKivHJctKWRdpxoJDQmsJMS2kR7yI8cdRrDHKYafWGNY7-iiGlulWkqPBHF8rUoJXfg"},"allowRememberMe":true,"rememberMe":false,"username":null,"externalProviders":[{"text":"Microsoft","href":"https://identity.reckon.com/external?provider=Microsoft&signin=cdf07a3cb572cd62438b93ab5fa39b48"},{"text":"Google","href":"https://identity.reckon.com/external?provider=Google&signin=cdf07a3cb572cd62438b93ab5fa39b48"}],"additionalLinks":null,"errorMessage":null,"requestId":"b07d58ce-9a48-448f-a665-31a40c08ae09","siteUrl":"https://identity.reckon.com/","siteName":"Reckon IdentityServer","currentUser":null,"logoutUrl":"https://identity.reckon.com/logout"}</script> <script src="/assets/scripts.js"></script> </body> </html> ]
And
Error:
org.apache.axis2.builder.BuilderUtil} - OMException in getSOAPBuilder org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createDTD(StAXSOAPModelBuilder.java:462) org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:282) org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:204) org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.(StAXSOAPModelBuilder.java:154) org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.(StAXSOAPModelBuilder.java:140) org.apache.axis2.builder.BuilderUtil.getSOAPBuilder(BuilderUtil.java:659) org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:206) org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:146) org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:109) org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:68) org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:348) org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:445) org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225) org.apache.axis2.client.OperationClient.execute(OperationClient.java:149) org.apache.synapse.message.senders.blocking.BlockingMsgSender.sendReceive(BlockingMsgSender.java:254) org.apache.synapse.message.senders.blocking.BlockingMsgSender.send(BlockingMsgSender.java:175) org.apache.synapse.mediators.builtin.CallMediator.handleBlockingCall(CallMediator.java:113) org.apache.synapse.mediators.builtin.CallMediator.mediate(CallMediator.java:85) org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:81) org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:48) org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:149) org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:175) org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180) org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:317) org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:149) org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) java.lang.Thread.run(Thread.java:748)
Did some one come a cross this issue before?
Enable message builder and formatter for conent-type text/xml(for html content) in /repository/conf/axis2/axis2.xml
Message builder
<messageBuilder contentType="text/html"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
Message formatter
<messageFormatter contentType="text/html"
class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
I've found the solution and posted it for other people like me.
We should add content type text/javascript to the axis2 file. As you can see from the log the response is a javascript.
<messageBuilder contentType="text/javascript"
class="org.apache.synapse.commons.json.JsonStreamBuilder"/>
<messageFormatter contentType="text/javascript"
class="org.apache.synapse.commons.json.JsonStreamFormatter"/>
Hope this would help other people.

Why does the first assert work, but not the second?

I'm using Watir WebDriver with Firefox.
Here are two asserts for the same element. The first works, but not the second:
assert_match(/Please add user to GMT/, #browser.small(:class, "error").text)
assert_match(/Please add user to GMT/, #browser.div(:class, "eight mobile-three columns").small(:class, "error").text)
I need the second assert to work, because there are 8 error messages on the page, which are presented if the user does not populate 8 mandatory fields. All 8 errors have the identical HTML. So, I need to be able to step down from the parent.
Here is the HTML:
<div class="eight mobile-three columns">
<a id="btnAddUserToGMT" class="success radius button expand error" onclick="AddUserToGMT();" data-reveal-id="addToGMT" href="#"> … </a>
<small class="error" style="margin-top:0px;">
Please add user to GMT
</small>
</div>
Here is the error message:
Watir::Exception::UnknownObjectException: unable to locate element, using {:class=>"error", :tag_name=>"small"}
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/elements/element.rb:490:in `assert_exists'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/elements/element.rb:85:in `text'
C:/Documents and Settings/Asserts_01.rb:22:in `testBasic'
The complaint for the second assert is:
unable to locate element, using {:class=>"error", :tag_name=>"small"}
And yet that same using was OK for the first assert.
Problem solved.
After discussion with the developer, it appears that by some unusual manipulation of automatically generated HTML, the text of the error message appears at its correct location on the page. But the assertion must be based on a different tag, which is specified at some completely different position on the page.
For example, I was trying to assert on this code at the correct position:
<small class="error" style="margin-top:0px;">
Gender is required
</small
Even unique xPath generated by FirePath failed to find this.
What I should have asserted on was a HIDDEN tag on a completely different part of the page.
<input id="errorMsgGenderID" name="errorMsgGenderID" type="hidden" value="Gender is required" />
There were several such tags for each mandatory field that was not populated, all bunched together on the same line. They were all "input" tags, which puzzled me.

Is the inputmode attribute valid (in HTML5 forms) or not?

I am getting validation errors with the inputmode attribute on text areas and text fields. The validator tells me Attribute inputmode not allowed on element input at this point but the HTML5 spec indicates that it is allowed.
Is there actually something wrong with this code, or is the validator at fault?
Here is a bare bones case which will produce exactly this kind of validation error (twice), in one case on an email input, and on the other on a textarea.
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<form method="post" action="contactme.php">
<label class='pas block'>
Your E-Mail:<br/>
<input type='email' name='email' required inputmode='latin' placeholder='your e-mail here' />
</label>
<label class='pas block'>
Your Message:<br/>
<textarea name='message' required inputmode='latin' placeholder='and your message here!'></textarea>
</label>
</form>
</body>
</html>
Also, see the chart about which attributes apply to the different input types here:
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#attr-input-type
The "inputmode" attribute applies only to "text" and "search".
UPDATE 2019-09-04: "inputmode" is now a global attribute (per WHATWG) and can be specified on any HTML element: https://html.spec.whatwg.org/multipage/dom.html#global-attributes
Another reference page for "inputmode":
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode
On another note, "inputmode" is not a W3C HTML5 attribute, but it is a W3C HTML 5.1 attribute (at least at the time I'm writing this). UPDATE 2019-09-04: "inputmode" has been removed from HTML 5.2 and HTML 5.3.
The HTML5 spec says
The following content attributes must not be specified and do not apply to the element: accept, alt, checked, dirname, formaction, formenctype, formmethod, formnovalidate, formtarget, height, inputmode, max, min, src, step, and width.
It's under bookkeeping details at https://html.spec.whatwg.org/multipage/input.html#e-mail-state-(type=email)
Five years after the question was asked, some may wonder why some of the properties listed by #dsas doesn't trigger such errors, like enctype
The answer is simple support, while enctype for instance gained a wide support
inputmethod is supported only as of IE11 and Edge 14, for more infos click here

Form post asp classic xmlhttp

I'm trying to do a form post from another site that is not mine, but
I am not able ta give error.
There on the site the post is mounted like this:
Veja o resultado da enquete anterior »
<br /><br />
<form name="result" action="http://enquete.terra.com.br/enquete.cgi" method="post">
<input type="hidden" name="id_enquete" value="144143">
<input type="hidden" name="opcao" value="0">
</form>
And I'm riding in the asp script to make this post as:
<%
Dim objHttp
Dim str
str = "id_enquete=144143&opcao=0"
Set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
objHttp.Open "POST", "http://enquete.terra.com.br/enquete.cgi", false
objHttp.setRequestHeader "Host", "http://enquete.terra.com.br"
objHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1"
objHttp.setRequestHeader "Content-Length", Len(str)
objHttp.Send str
Response.Write(objHttp.ResponseText)
Set objHttp = nothing
%>
But not this working, does anyone know how or know where I am
wrong??
Thanks
You can't make cross domain request using AJAX due to the same origin policy. If the other site supports JSONP, you can use a script request to access the site and get data from it, of course, your parameters need to be in the URL for that to work.
<script type="text/javascript">
function resultCallback( data ) {
// do something with the returned JSON data
}
</script>
<script type="text/javascript" src="http://enquete.terra.com.br/enquete.cgi?id_enquete=144143&opacao=0&callback=resultCallback">
</script>
Code looks true; the reason why you get "Internal Server Error" is because your IIS settings for error is not in the debug mode.
You should change your IIS settings to "Send error messages to Browser" then you can see the actual error message on the browser; which is probably caused by version of the Msxml2.ServerXMLHTTP object.