Subject:Problems posting multipart form via http-post Author:Bruce Cantor Date:06 Oct 2023 01:50 PM
I am having trouble making a http-post via Xquery in Stylus studio.
I have created a successfully post via Postman but cannot recreate the success in Xquery in Stylus Studio.
In Postman this exported code is working successfully:
POST /api/private/portugal/invoice-sender-feedback HTTP/1.1
Host: sii.marosavat.com
Environment: TEST
Company: PT501234569
Id: 4587
Authorization: Basic YnQuY2FudG9yQGVldGdyb3VwLmNb==
Content-Length: 257
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
When I run the Xquery code I get an error 400-bad request.
Am I doing this correct? I am thinking that I might be setting the multipart file part wrong?
Subject:Problems posting multipart form via http-post Author:Ivan Pedruzzi Date:06 Oct 2023 04:11 PM
You should not try to handle authentication manually, ddtek:http functions support and user/password for BASIC and DIGEST
Mime type it is also managed automatically.
Try the above first, if the multi-part is really a requirement. you may need to use a different function.
Here is an example of extension function HTTP.VERB available from XPS build 150 or greater, which was designed to be compatible with ddtek:http option and response.
Element "parameter" you can point to a local file using local path.
Attribute "type" supports 3 values: file, base64, text
When type is base64 or text you need to place the value directly as text, see second example.
declare namespace xps_http = 'ddtekjava:com.ivitechnologies.pipeline.ext.net.HTTP';\n";
declare function xps_http:VERB($verb as xs:string, $url, $options as document-node()?, $payload as document-node()?) external;\n";
[DataDirect][XQuery]Error at line 33, column 87. Static error during resolving of external Java function. No matching Java external function found for 'com.ivitechnologies.pipeline.ext.net.HTTP:VERB(xs:string, attribute(URLInvoiceCreditNote, xs:untypedAtomic)*, document-node()?, document-node()?)'. [Call stack: xps_http:VERB@33.8]
javax.xml.xquery.XQQueryException: [DataDirect][XQuery]Error at line 33, column 87. Static error during resolving of external Java function. No matching Java external function found for 'com.ivitechnologies.pipeline.ext.net.HTTP:VERB(xs:string, attribute(URLInvoiceCreditNote, xs:untypedAtomic)*, document-node()?, document-node()?)'. [Call stack: xps_http:VERB@33.8]
at com.ddtek.xquery.xqj.Util.createXQQueryException(Util.java:341)
at com.ddtek.xquery.xqj.Util.createXQException(Util.java:241)
at com.ddtek.xquery.xqj.DDXQAbstractExpression.createOrGetExecutionContext(DDXQAbstractExpression.java:519)
at com.ddtek.xquery.xqj.DDXQAbstractExpression.createOrGetExecutionContext(DDXQAbstractExpression.java:481)
at com.ddtek.xquery.xqj.DDXQPreparedExpression.<init>(DDXQPreparedExpression.java:37)
at com.ddtek.xquery.xqj.DDXQConnection.prepareExpression(DDXQConnection.java:243)
Caused by: com.ddtek.xquery.typing.TypeVisitor$TypeVisitorException: [EJF0002][DataDirect][XQuery]Static error during resolving of external Java function. No matching Java external function found for 'com.ivitechnologies.pipeline.ext.net.HTTP:VERB(xs:string, attribute(URLInvoiceCreditNote, xs:untypedAtomic)*, document-node()?, document-node()?)'. [Call stack: xps_http:VERB@33.8]
at com.ddtek.xquery.typing.TypeVisitor.createException(TypeVisitor.java:5111)
at com.ddtek.xquery.typing.TypeVisitor.getExternalJavaFunction(TypeVisitor.java:7775)
at com.ddtek.xquery.typing.TypeVisitor.visit(TypeVisitor.java:2980)
at com.ddtek.xquery.expr.FunctionCall.accept(FunctionCall.java:224)
at com.ddtek.xquery.typing.TypeVisitor.visit(TypeVisitor.java:2794)
at com.ddtek.xquery.expr.FLWORExpr.accept(FLWORExpr.java:204)
at com.ddtek.xquery.expr.AllExpressionVisitor.visit(AllExpressionVisitor.java:455)
at com.ddtek.xquery.typing.TypeVisitor.visit(TypeVisitor.java:3450)
at com.ddtek.xquery.expr.MainModule.accept(MainModule.java:57)
at com.ddtek.xquery.typing.TypeVisitor.typeExpression(TypeVisitor.java:740)
at com.ddtek.xquery.mediator.ContextFactory$MediatorTypeVisitor.typeExpression(ContextFactory.java:581)
at com.ddtek.xquery.mediator.ContextFactory.prepareQuery(ContextFactory.java:254)
at com.ddtek.xquery.xqj.DDXQAbstractExpression.createOrGetExecutionContext(DDXQAbstractExpression.java:512)
... 3 more
In the classpath I am refering to the latest xmlpipelineserver.jar that I copied from the pipeline server. (MD-5: 0x99C067E7B4C8DC6264C1B2CC1F62B050).
Subject:Problems posting multipart form via http-post Author:Bruce Cantor Date:10 Oct 2023 08:43 AM
Dear Ivan,
Please remind me, where can I find the documentation for the ivitechnologies.pipeline java classes (including com.ivitechnologies.pipeline.ext.net.HTTP)?
Your help is much appreciated, but without the documentation I am coding in the dark and very much depended on your input.
I added some more libraries as suggested and I think I got closer but stuck in something that looks like as if I am not getting the username, password correctly sent.
This solution gives an "Not authorized error":
let $options := document {<request username="****" password="*******">
<request-header>
If I try your latest method where an additional payload parameter is added, I get an error saying: Exception in extension function "java.lang.IllegalStateException: Name is blank"