This post was updated on .
Is it possible to submit data from a form to an API service by having the user click on the form submit button? I created an action that is triggered by a form button (api-button). The action initiates an Http Post service. In the xml file defined here I have xml fields called, for example, employee_id that match the control name i.e. Control Name: employee_id. I am getting an error when I try to submit data: "There was an error communicating with a backend service".
First tab on Actions: Second tab on Actions (I have not added anything to the third tab): |
Update: this was all correct (except the second tab of the actions should have been encoded as /request/employee_id, for example) but there was a firewall issue blocking communication with the API.
|
Administrator
|
> Update: this was all correct (except the second tab of the actions should have been encoded as /request/employee_id, for example) but there was a firewall issue blocking communication with the API.
Good to read. For this, though, you could (should probably) use a process with a send action instead: https://doc.orbeon.com/form-runner/advanced/buttons-and-processes/actions-form-runner/actions-form-runner-send -Erik |
This post was updated on .
Thank you for your response, Erik.
I am not sure what you mean regarding I should have a send action, as I think I have that set up in the first tab of the Actions editor. Do you mean putting the following code in properties-local.xml? We are trying to use POST, incidentally, not PUT. <property as="xs:string" name="oxf.fr.detail.process.send.my-app.my-form" > send( uri = "http://example.org/accept-form", method = "PUT", content = "metadata" ) </property> Note that I was only able to get it working with a custom Send button, as referred to on the first tab of the Actions editor, above (Form builder method). We would prefer to use a send button defined in the code (Form runner method). However, when we try that the request to the CDATA API sees a query string appended and it is not REST encoded. Here is what we have in the definition for the form. I have obscured portions of the API for security. Is there anything we can add here to ensure that the request is not sent with a query string attached and is html encoded as I've done in the screen shots, above? xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:bcgov="http://www.gov.bc.ca/"> <property as="xs:string" name="oxf.fr.detail.buttons.gov-psa.API-test">clear pdf send</property> <property as="xs:string" name="oxf.fr.detail.button.send.enabled.gov-psa.API-test" value="not(//submitted = 'true')"/> <property as="xs:boolean" name="oxf.fr.email.attach-xml.gov-psa.API-test" value="true"/> <property as="xs:string" name="oxf.fr.detail.process.send.gov-psa.API-test"> require-valid then send( uri = "https://telework.some address", method = "POST", nonrelevant = "keep" ) then email then xf:setvalue(ref = "//submitted", value = "'true'") then ( success-message(message = "Thank you for your submission. 1") then success-message(message = "Your request is sent. Please check your email.") then navigate(uri = "javascript:window.govFormActionHandler('submit')") ) then set-data-status(status = "safe") recover ( error-message(message = "We are sorry. Your submission did not go through. Please try again.") then navigate(uri = "javascript:window.govFormActionHandler('submission-error')") ) </property> </properties> Here is what the API sees when it fails. I follow it what the API sees when it works. Note the query string, as we don't know where that is coming from, nor why the contentType=application/xml (I've altered the authentication string here): Request that doesn't work (Form Runner button method): https-jsse-nio-443-exec-8 START TIME =30-Jul-2021 16:16:46 https-jsse-nio-443-exec-8 requestURI=/apiserver/api.rsc/Datamart_TeleWork_dbo_employee_record_upload/ https-jsse-nio-443-exec-8 authType=null https-jsse-nio-443-exec-8 characterEncoding=null https-jsse-nio-443-exec-8 contentLength=730 https-jsse-nio-443-exec-8 contentType=application/xml https-jsse-nio-443-exec-8 contextPath=/apiserver https-jsse-nio-443-exec-8 header=orbeon-client=portlet https-jsse-nio-443-exec-8 header=content-type=application/xml https-jsse-nio-443-exec-8 header=content-length=730 https-jsse-nio-443-exec-8 header=host=analytics-testapi.psa.gov.bc.ca https-jsse-nio-443-exec-8 header=connection=Keep-Alive https-jsse-nio-443-exec-8 header=authorization=Basic dGVsZXdvcms6OW4xUDV5NHQzUTZwM2c2Vz= https-jsse-nio-443-exec-8 header=accept-encoding=gzip,deflate https-jsse-nio-443-exec-8 locale=en_US https-jsse-nio-443-exec-8 method=POST https-jsse-nio-443-exec-8 parameter=app=gov-psa https-jsse-nio-443-exec-8 parameter=form=API-test https-jsse-nio-443-exec-8 parameter=form-version=19 https-jsse-nio-443-exec-8 parameter=document=9929fa266a8d374318908ccf8a0e865f25e9c8be https-jsse-nio-443-exec-8 parameter=valid=true https-jsse-nio-443-exec-8 parameter=language=en https-jsse-nio-443-exec-8 parameter=process=41eb891c2cfba83d7d12918895b94661a20ba162 https-jsse-nio-443-exec-8 parameter=data-format-version=4.0.0 https-jsse-nio-443-exec-8 pathInfo=/Datamart_TeleWork_dbo_employee_record_upload/ https-jsse-nio-443-exec-8 protocol=HTTP/1.1 https-jsse-nio-443-exec-8 queryString=app=gov-psa&form=API-test&form-version=19&document=9929fa266a8d374318908ccf8a0e865f25e9c8be&valid=true&language=en&process=41eb891c2cfba83d7d12918895b94661a20ba162&data-format-version=4.0.0 https-jsse-nio-443-exec-8 remoteAddr=142.34.249.100 https-jsse-nio-443-exec-8 remoteHost=142.34.249.100 https-jsse-nio-443-exec-8 remoteUser=null https-jsse-nio-443-exec-8 requestedSessionId=null https-jsse-nio-443-exec-8 scheme=https https-jsse-nio-443-exec-8 serverName=analytics-testapi.psa.gov.bc.ca https-jsse-nio-443-exec-8 serverPort=443 https-jsse-nio-443-exec-8 servletPath=/api.rsc https-jsse-nio-443-exec-8 isSecure=true https-jsse-nio-443-exec-8 ------------------=-------------------------------------------- Executing the following query: INSERT INTO [Datamart_TeleWork].[dbo].[employee_record_upload] ([app], [valid], [process], [form], [document], [language], [data-format-version], [form-version]) VALUES (?, ?, ?, ?, ?, ?, ?, ?);1=gov-psa(string);2=true(string);3=41eb891c2cfba83d7d12918895b94661a20ba162(string);4=API-test(string);5=9929fa266a8d374318908ccf8a0e865f25e9c8be(string);6=en(string);7=4.0.0(string);8=19(double) Retrieving insert row from query: SELECT * FROM [Datamart_TeleWork].[dbo].[employee_record_upload] WHERE ((((((([app] LIKE ?) AND ([valid] LIKE ?)) AND ([process] LIKE ?)) AND ([form] LIKE ?)) AND ([document] LIKE ?)) AND ([language] LIKE ?)) AND ([data-format-version] LIKE ?)) AND ([form-version] = ?);1=gov-psa(string);2=true(string);3=41eb891c2cfba83d7d12918895b94661a20ba162(string);4=API-test(string);5=9929fa266a8d374318908ccf8a0e865f25e9c8be(string);6=en(string);7=4.0.0(string);8=19(double) https-jsse-nio-443-exec-8 ------------------=-------------------------------------------- https-jsse-nio-443-exec-8 authType=null https-jsse-nio-443-exec-8 contentType=application/json;charset=utf-8 https-jsse-nio-443-exec-8 header=X-Powered-By=CData API Server https-jsse-nio-443-exec-8 header=X-DateTime-Format=yyyy-MM-dd'T'HH:mm:ss.ffffzzz https-jsse-nio-443-exec-8 header=OData-Version=4.0; https-jsse-nio-443-exec-8 header=Location=https://analytics-testapi.psa.gov.bc.ca/apiserver/api.rsc/Datamart_TeleWork_dbo_employee_record_upload(0) https-jsse-nio-443-exec-8 header=Content-Type=application/json;charset=utf-8 https-jsse-nio-443-exec-8 header=Transfer-Encoding=chunked https-jsse-nio-443-exec-8 header=Date=Fri, 30 Jul 2021 23:16:47 GMT https-jsse-nio-443-exec-8 header=Keep-Alive=timeout=60 https-jsse-nio-443-exec-8 header=Connection=keep-alive https-jsse-nio-443-exec-8 remoteUser=null https-jsse-nio-443-exec-8 status=201 https-jsse-nio-443-exec-8 END TIME =30-Jul-2021 16:16:47 Request that works (Form Builder button method): https-jsse-nio-443-exec-7 requestURI=/apiserver/api.rsc/Datamart_TeleWork_dbo_employee_record_upload/ https-jsse-nio-443-exec-7 authType=null https-jsse-nio-443-exec-7 characterEncoding=null https-jsse-nio-443-exec-7 contentLength=283 https-jsse-nio-443-exec-7 contentType=application/x-www-form-urlencoded https-jsse-nio-443-exec-7 contextPath=/apiserver https-jsse-nio-443-exec-7 header=orbeon-client=portlet https-jsse-nio-443-exec-7 header=content-type=application/x-www-form-urlencoded https-jsse-nio-443-exec-7 header=content-length=283 https-jsse-nio-443-exec-7 header=host=analytics-testapi.psa.gov.bc.ca https-jsse-nio-443-exec-7 header=connection=Keep-Alive https-jsse-nio-443-exec-7 header=authorization=Basic dGVsZXdvcms6OW4xUDV5NHQzUTZwM2c2V= https-jsse-nio-443-exec-7 header=accept-encoding=gzip,deflate https-jsse-nio-443-exec-7 locale=en_US https-jsse-nio-443-exec-7 method=POST https-jsse-nio-443-exec-7 parameter=employee_id=100001 https-jsse-nio-443-exec-7 parameter=ministry=Ministry of Poultry https-jsse-nio-443-exec-7 parameter=ministry_code=BC022 https-jsse-nio-443-exec-7 parameter=dept_id=2456 https-jsse-nio-443-exec-7 parameter=name_first=Tommy https-jsse-nio-443-exec-7 parameter=name_last=Turkey https-jsse-nio-443-exec-7 parameter=city=Victoria https-jsse-nio-443-exec-7 parameter=wfh_monday=YES https-jsse-nio-443-exec-7 parameter=wfh_tuesday=YES https-jsse-nio-443-exec-7 parameter=wfh_wednesday=YES https-jsse-nio-443-exec-7 parameter=wfh_thursday=YES https-jsse-nio-443-exec-7 parameter=wfh_friday=YES https-jsse-nio-443-exec-7 parameter=date_applied=2021-06-01 https-jsse-nio-443-exec-7 parameter=date_approved=2021-06-01 https-jsse-nio-443-exec-7 parameter=date_modified=1900-01-01 https-jsse-nio-443-exec-7 pathInfo=/Datamart_TeleWork_dbo_employee_record_upload/ https-jsse-nio-443-exec-7 protocol=HTTP/1.1 https-jsse-nio-443-exec-7 queryString=null https-jsse-nio-443-exec-7 remoteAddr=142.34.249.100 https-jsse-nio-443-exec-7 remoteHost=142.34.249.100 https-jsse-nio-443-exec-7 remoteUser=null https-jsse-nio-443-exec-7 requestedSessionId=null https-jsse-nio-443-exec-7 scheme=https https-jsse-nio-443-exec-7 serverName=analytics-testapi.psa.gov.bc.ca https-jsse-nio-443-exec-7 serverPort=443 https-jsse-nio-443-exec-7 servletPath=/api.rsc https-jsse-nio-443-exec-7 isSecure=true Or, I am wondering if the problem is at the top of the page, where there is a reference to SOAP encoding, below. Should I change that reference to soap to something else? Note that the data format version in the code below is sent as one of the query string parameters in the attempt that fails. <xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:saxon="http://saxon.sf.net/" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sql="http://orbeon.org/oxf/xml/sql" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:exf="http://www.exforms.org/exf/1-0" xmlns:array="http://www.w3.org/2005/xpath-functions/array" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fb="http://orbeon.org/oxf/xml/form-builder" xmlns:map="http://www.w3.org/2005/xpath-functions/map" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" fr:data-format-version="4.0.0"> |
Administrator
|
Yes, I should clarify: buttons and processes and the `send` action are completely separate from actions and services that you see in Form Builder. (This is not ideal and we'd like to unify the two at some point.)
So yes, I was referring to adding this in properties-local.xml. The query string you are seeing comes standard. You can remove it by passing the following to the `send` action: parameters = "" See: https://doc.orbeon.com/form-runner/advanced/buttons-and-processes/actions-form-runner/actions-form-runner-send#url-format I hope this helps, -Erik |
Hi Erik,
Thanks for your response. I think that's part of it. We've simplified the properties-local.xml to the following (I've again altered the username and password). I've also added the code from the form itself. <properties xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:bcgov="http://www.gov.bc.ca/"> <property as="xs:string" name="oxf.fr.detail.buttons.gov-psa.API-test">pdf clear send</property> <property as="xs:string" name="oxf.fr.detail.process.send.gov-psa.API-test"> require-valid then send( uri = "https://tele:9n1Pp3g@analytics-testapi.psa.gov.bc.ca/apiserver/api.rsc/Datamart_TeleWork_dbo_employee_record_upload/", method = "POST", parameters = "", nonrelevant = "keep" ) then success-message(message = "Your request is sent.") recover ( error-message(message = "We are sorry. Your submission did not go through. Please try again.") ) </property> </properties> We get the "so sorry" message and the following is a 404 error that pops up in the log now. Note: I am running all of this on a trial version of Orbeon on my laptop. That shouldn't affect anything, should it? 0:0:0:0:0:0:0:1 - - [04/Aug/2021:16:55:34 -0700] "GET /orbeon/xforms-server/1aab5d9281c32500badaf730be9891634ec77eb1/Hint.min.js.map HTTP/1.1" 404 <xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:saxon="http://saxon.sf.net/" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sql="http://orbeon.org/oxf/xml/sql" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:exf="http://www.exforms.org/exf/1-0" xmlns:array="http://www.w3.org/2005/xpath-functions/array" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fb="http://orbeon.org/oxf/xml/form-builder" xmlns:map="http://www.w3.org/2005/xpath-functions/map" fr:data-format-version="4.0.0"> <xh:head> <xh:title>Telus API testing form</xh:title> <xf:model id="fr-form-model" xxf:expose-xpath-types="true" xxf:analysis.calculate="true"> <xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all" xxf:index="id"> <form> <submitted>false</submitted> <section-1> <grid-1> <employee_id>101010</employee_id> <ministry>Ministry of Poultry</ministry> <ministry_code>BC022</ministry_code> <dept_id>2456</dept_id> <name_first>Emily</name_first> <name_last>Emu</name_last> <city>Victoria</city> <wfh_monday>true</wfh_monday> <wfh_tuesday>true</wfh_tuesday> <wfh_wednesday>true</wfh_wednesday> <wfh_thursday>true</wfh_thursday> <wfh_friday>true</wfh_friday> <date_applied>2021-06-01</date_applied> <date_approved>2021-06-01</date_approved> <date_modified>2021-06-01</date_modified> </grid-1> </section-1> </form> </xf:instance> <xf:bind id="fr-form-binds" ref="instance('fr-form-instance')"> <xf:bind id="section-1-bind" name="section-1" ref="section-1"> <xf:bind id="grid-1-bind" ref="grid-1" name="grid-1"> <xf:bind id="employee_id-bind" ref="employee_id" name="employee_id" xxf:whitespace="trim"/> <xf:bind id="ministry_code-bind" ref="ministry_code" name="ministry_code" xxf:whitespace="trim"/> <xf:bind id="ministry-bind" ref="ministry" name="ministry" xxf:whitespace="trim"/> <xf:bind id="dept_id-bind" ref="dept_id" name="dept_id" xxf:whitespace="trim"/> <xf:bind id="name_first-bind" ref="name_first" name="name_first" xxf:whitespace="trim"/> <xf:bind id="name_last-bind" ref="name_last" name="name_last" xxf:whitespace="trim"/> <xf:bind id="city-bind" ref="city" name="city" xxf:whitespace="trim"/> <xf:bind id="wfh_monday-bind" ref="wfh_monday" name="wfh_monday" type="xf:boolean"/> <xf:bind id="wfh_tuesday-bind" ref="wfh_tuesday" name="wfh_tuesday" type="xf:boolean"/> <xf:bind id="wfh_wednesday-bind" ref="wfh_wednesday" name="wfh_wednesday" type="xf:boolean"/> <xf:bind id="wfh_thursday-bind" ref="wfh_thursday" name="wfh_thursday" type="xf:boolean"/> <xf:bind id="wfh_friday-bind" ref="wfh_friday" name="wfh_friday" type="xf:boolean"/> <xf:bind id="date_approved-bind" ref="date_approved" name="date_approved" xxf:whitespace="trim"/> <xf:bind id="date_modified-bind" ref="date_modified" name="date_modified" xxf:whitespace="trim"/> <xf:bind id="date_applied-bind" ref="date_applied" name="date_applied" xxf:whitespace="trim"/> </xf:bind> </xf:bind> </xf:bind> <xf:instance id="fr-form-metadata" xxf:readonly="true" xxf:exclude-result-prefixes="#all"> <metadata> <application-name>gov-psa</application-name> <form-name>API-test</form-name> <title xml:lang="en">Telus API testing form</title> <description xml:lang="en">Form runner button test</description> <created-with-version>2020.1.3.202105010041 PE</created-with-version> <updated-with-version>2020.1.3.202105010041 PE</updated-with-version> <body> <fr:param type="ControlValueParam"> <fr:name>email</fr:name> <fr:controlName>email</fr:controlName> </fr:param> </body> <library-versions> <orbeon>1</orbeon> </library-versions> </metadata> </xf:instance> <xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all"> <attachments/> </xf:instance> <xf:instance xxf:readonly="true" id="fr-form-resources" xxf:exclude-result-prefixes="#all"> <resources> <resource xml:lang="en"> <employee_id> <label>employee_id</label> <hint/> </employee_id> <ministry> <label>ministry</label> <hint/> </ministry> <ministry_code> <label>ministry_code</label> <hint/> </ministry_code> <dept_id> <label>dept_id</label> <hint/> </dept_id> <name_first> <label>name_first</label> <hint/> </name_first> <name_last> <label>name_last</label> <hint/> </name_last> <city> <label>city</label> <hint/> </city> <wfh_monday> <label>wfh_monday</label> <hint/> </wfh_monday> <wfh_tuesday> <label>wfh_tuesday</label> <hint/> </wfh_tuesday> <wfh_wednesday> <label>wfh_wednesday</label> <hint/> </wfh_wednesday> <wfh_thursday> <label>wfh_thursday</label> <hint/> </wfh_thursday> <wfh_friday> <label>wfh_friday</label> <hint/> </wfh_friday> <date_applied> <label>date_applied</label> <hint/> </date_applied> <date_approved> <label>date_approved</label> <hint/> </date_approved> <date_modified> <label>date_modified</label> <hint/> </date_modified> <section-1> <label>form with embedded code</label> </section-1> </resource> </resources> </xf:instance> </xf:model> <xf:submit submission="my-submission"> <xf:label>Submit</xf:label> </xf:submit> </xh:head> <xh:body> <fr:view> <fr:body xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors"> <fr:section id="section-1-section" bind="section-1-bind"> <xf:label ref="$form-resources/section-1/label"/> <fr:grid id="grid-1-grid" bind="grid-1-bind"> <fr:c y="1" x="1" w="6"> <xf:input id="employee_id-control" bind="employee_id-bind"> <xf:label ref="$form-resources/employee_id/label"/> <xf:hint ref="$form-resources/employee_id/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </xf:input> </fr:c> <fr:c y="1" x="7" w="6"> <xf:input id="ministry-control" bind="ministry-bind"> <xf:label ref="$form-resources/ministry/label"/> <xf:hint ref="$form-resources/ministry/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </xf:input> </fr:c> <fr:c x="1" y="2" w="6"> <xf:input id="ministry_code-control" bind="ministry_code-bind"> <xf:label ref="$form-resources/ministry_code/label"/> <xf:hint ref="$form-resources/ministry_code/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </xf:input> </fr:c> <fr:c x="7" y="2" w="6"> <xf:input id="dept_id-control" bind="dept_id-bind"> <xf:label ref="$form-resources/dept_id/label"/> <xf:hint ref="$form-resources/dept_id/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </xf:input> </fr:c> <fr:c x="1" y="3" w="6"> <xf:input id="name_first-control" bind="name_first-bind"> <xf:label ref="$form-resources/name_first/label"/> <xf:hint ref="$form-resources/name_first/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </xf:input> </fr:c> <fr:c x="7" y="3" w="6"> <xf:input id="name_last-control" bind="name_last-bind"> <xf:label ref="$form-resources/name_last/label"/> <xf:hint ref="$form-resources/name_last/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </xf:input> </fr:c> <fr:c x="1" y="4" w="6"> <xf:input id="city-control" bind="city-bind"> <xf:label ref="$form-resources/city/label"/> <xf:hint ref="$form-resources/city/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </xf:input> </fr:c> <fr:c x="7" y="4" w="6"> <fr:yesno-input id="wfh_monday-control" bind="wfh_monday-bind"> <xf:label ref="$form-resources/wfh_monday/label"/> <xf:hint ref="$form-resources/wfh_monday/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </fr:yesno-input> </fr:c> <fr:c x="1" y="5" w="6"> <fr:yesno-input id="wfh_tuesday-control" bind="wfh_tuesday-bind"> <xf:label ref="$form-resources/wfh_tuesday/label"/> <xf:hint ref="$form-resources/wfh_tuesday/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </fr:yesno-input> </fr:c> <fr:c x="7" y="5" w="6"> <fr:yesno-input id="wfh_wednesday-control" bind="wfh_wednesday-bind"> <xf:label ref="$form-resources/wfh_wednesday/label"/> <xf:hint ref="$form-resources/wfh_wednesday/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </fr:yesno-input> </fr:c> <fr:c x="1" y="6" w="6"> <fr:yesno-input id="wfh_thursday-control" bind="wfh_thursday-bind"> <xf:label ref="$form-resources/wfh_thursday/label"/> <xf:hint ref="$form-resources/wfh_thursday/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </fr:yesno-input> </fr:c> <fr:c x="7" y="6" w="6"> <fr:yesno-input id="wfh_friday-control" bind="wfh_friday-bind"> <xf:label ref="$form-resources/wfh_friday/label"/> <xf:hint ref="$form-resources/wfh_friday/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </fr:yesno-input> </fr:c> <fr:c x="1" y="7" w="6"> <xf:input id="date_applied-control" bind="date_applied-bind"> <xf:label ref="$form-resources/date_applied/label"/> <xf:hint ref="$form-resources/date_applied/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </xf:input> </fr:c> <fr:c x="7" y="7" w="6"> <xf:input id="date_approved-control" bind="date_approved-bind"> <xf:label ref="$form-resources/date_approved/label"/> <xf:hint ref="$form-resources/date_approved/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </xf:input> </fr:c> <fr:c x="1" y="8" w="6"> <xf:input id="date_modified-control" bind="date_modified-bind"> <xf:label ref="$form-resources/date_modified/label"/> <xf:hint ref="$form-resources/date_modified/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </xf:input> </fr:c> <fr:c x="7" y="8" w="6"/> </fr:grid> </fr:section> </fr:body> </fr:view> </xh:body> </xh:html> |
Administrator
|
The process failed and you are getting the error probably either because:
- `require-valid` failed - or `send` failed It's probably the latter, but just in case first remove the first: `require-valid then` and start with the `send` action. If `send` fails then check orbeon.log to see if there is an error there. The `Hint.min.js.map` 404 error is not an issue: it's just the browser trying to open a source map when you are using the dev tools. -Erik |
Thanks for the fast reply. It wasn't require-valid: I'll dig into the logs.
|
I see two issues in the logs that jump out:
This occurs numerous times in the log: |An Error has Occurred | |----------------------------------------------------------------------------------------------------------------------| |Required item type of first operand of '/' is node(); supplied value has item type xs:string and this is towards the end. Exception: org.orbeon.oxf.xforms.action.XFormsAPI$SubmitException | |------------------------------------------------------------------ This looks similar to this thread, but I don't understand what it has in common. Something about writing to the database? I am trying to post to an external API. https://discuss.orbeon.com/Cant-get-Community-or-PE-edition-Form-Runner-working-or-to-publish-save-td4661098.html |
Administrator
|
The first error is covered by:
https://github.com/orbeon/orbeon-forms/issues/4877 It will be fixed in 2020.4, but it's not impacting anything except the logs. The second error is telling us that the submission, that is the all call to the service, is failing. It's not about writing to the database but about calling that service. So I don't think it's related to the thread you are linking to. Can you see whether your target service receives the request? That service probably has access logs or an error log. If the request makes to that service, maybe it will log what's wrong with the request if anything. Try also sending to a test service that just echoes or records the request. -Erik |
The test service successfully received the XML (I simply swapped out the URI). For some reason the one we *want* to reach, a CDATA API (based on CDATA.Com software), doesn't like our attempts. Unfortunately it is a contractor and they are having trouble diagnosing the issue. If you have heard issues with CDATA implementations I'd be grateful for tips. Thanks for all your help up to this point.
|
Administrator
|
Good to hear that it's at least calling the test service.
So something must be different between the format that Orbeon Forms sends vs. the format expected by the CDATA API. We don't have experience with these APIs specifically. Possibly you could setup an HTTP proxy which might allow you to fully monitor the requests and responses between Orbeon Forms and the other system. It could be anything but, for development, we often use Charles Proxy: https://www.charlesproxy.com/ See how you can configure Orbeon Forms to use a proxy for outgoing HTTP requests: https://doc.orbeon.com/configuration/properties/general/properties-general-http-client#proxy-setup -Erik |
Thanks Erik - I learned of Charles a few days ago and I'm trying to do just that. I will report back when I discover what the cause is.
|
We've learned that we need that CONTENT-TYPE has to be application/atom+xml. Is it possible to set that for a POST in Form runner? I am guessing it would go in properties-local.xml
|
Administrator
|
There is no UI for it, but with "Edit Source", find the `<xf:submission>` for that service, and update the `mediatype` attribute. For example:
<xf:submission id="my-submission" class="fr-service" resource="/fr/service/custom/orbeon/echo" method="post" serialization="application/xml" mediatype="application/atom+xml"/> This might do the trick. |
Administrator
|
I just realized that you might be using the `send()` function, and not an HTTP service in Form Builder.
If that's the case, pass the additional `mediatype` parameter: send( ... mediatype = "application/atom+xml" ) I hope this helps. |
Administrator
|
Sorry, mistake: the name of the parameter is `content-type`, not `mediatype`, so:
send( ... content-type = "application/atom+xml" ) |
Thanks - no success yet but we are double checking everything.
|
This post was updated on .
Still no success. I am wondering what the equivalent coding is for the following test where I am sending an XML file by POST to the same API. I can send this successfully when I click Test, but I continue to get an error due to our attempts through a submission coded via properties-local.xml. I am looking at setting up a proxy in between Orbeon and the API to capture the encoding of this, but I am hoping someone might just be able to tell me what the equivalent would be in properties-local.xml. It appears to be the following:
< xf:submission id="api_test-submission" class="fr-service" resource="https://my_uri" method="post" serialization="application/x-www-form-urlencoded" mediatype="application/x-www-form-urlencoded" xxf:username="my_username" xxf:password="my_password" > The echo of the Form runner output follows. It is followed by the properties-local.xml that produced this output. With the regular properties-local.xml version that is similarly coded, the authentication is of the form uri = "https://username:password@uri". Is this way of encoding the username and password permissible in the properties-local.xml file? |
Free forum by Nabble | Edit this page |