How to make an API Call from a Form?
Asked by n_travaglini:

Hi

I am trying to call an API according to the following documentation: <https://www.cirrnet.ch/service.asmx>. However, I am not sure how to embed this in an according form or via which Addon (e.g. Comfiforms) since the Post is being blocked. Does anyone have an idea on how API can be directly reached?

BR


Answers:
author: Alex Medved _ConfiForms_
body: Hi [@n_travaglini](/t5/user/viewprofilepage/user-id/5574053)

Are you trying to set up a ConfiForms form that will do a web-request to one of your services?

That is possible. ConfiForms offers a way to call any service via <https://wiki.vertuna.com/display/CONFIFORMS/Configuring+ConfiForms+IFTTT+actions+and+rules#ConfiguringConfiFormsIFTTTactionsandrules-WebServiceRequest>

Alex

comments: author: n_travaglini
body: Hi Alex

Thanks a lot for your response and the link. I actually found that documentation before but had troubles with setting it up. Therefore I alternatively tried an html form, from which the request got blocked by the server.

Are you familiar with the correct setup?

Thanks a lot an br


author: Alex Medved _ConfiForms_
body: If you try to do it via HTML and browser request you quickly end up with cross-domain requests that quickly get blocked

What was not working for you with ConfiForms webservice request?


author: n_travaglini
body: Hi Alex

Actually all the configuration is clear, but when I try to adjust the Body Storage format, it does not get saved properly. In my opinion, it should be something like this (I configured the fields the same way as given by the definition in <https://www.cirrnet.ch/service.asmx>):  

*\<soapenv:Envelope xmlns:soapenv="<http://schemas.xmlsoap.org/soap/envelope/>" xmlns:web="<http://tempuri.org/>"\>*   
*\<soapenv:Header/\>*   
*\<soapenv:Body\>*   
*\<web:ImportCirrnet\>*   
*\<web:IdFachbereich\>*   
*\<ac:structured-macro ac:name="confiform-field"\>*   
*\<ac:parameter ac:name="fieldName"\>IdFachbereich\</ac:parameter\>*   
*\</ac:structured-macro\>*   
*\</web:IdFachbereich\>*   
*\<web:MassngepO\>*   
*\<ac:structured-macro ac:name="confiform-field"\>*   
*\<ac:parameter ac:name="fieldName"\>MassngepO\</ac:parameter\>*   
*\</ac:structured-macro\>*   
*\</web:MassngepO\>*   
*\<web:MassngetO\>*   
*\<ac:structured-macro ac:name="confiform-field"\>*   
*\<ac:parameter ac:name="fieldName"\>MassngetO\</ac:parameter\>*   
*\</ac:structured-macro\>*   
*\</web:MassngetO\>*   
*\<web:EreignisO\>*   
*\<ac:structured-macro ac:name="confiform-field"\>*   
*\<ac:parameter ac:name="fieldName"\>EreignisO\</ac:parameter\>*   
*\</ac:structured-macro\>*   
*\</web:EreignisO\>*   
*\<web:DatEreignis\>*   
*\<ac:structured-macro ac:name="confiform-field"\>*   
*\<ac:parameter ac:name="fieldName"\>DatEreignis\</ac:parameter\>*   
*\</ac:structured-macro\>*   
*\</web:DatEreignis\>*   
*\<web:aldLogin\>*   
*\<ac:structured-macro ac:name="confiform-field"\>*   
*\<ac:parameter ac:name="fieldName"\>aldLogin\</ac:parameter\>*   
*\</ac:structured-macro\>*   
*\</web:aldLogin\>*   
*\<web:aPwd\>*   
*\<ac:structured-macro ac:name="confiform-field"\>*   
*\<ac:parameter ac:name="fieldName"\>aPwd\</ac:parameter\>*   
*\</ac:structured-macro\>*   
*\</web:aPwd\>*   
*\</web:ImportCirrnet\>*   
*\</soapenv:Body\>*   
*\</soapenv:Envelope\>*   

However, this is overwritten by confiforms. Here is the configuration of the IFTTT, do you see a potential error?

![Attachment 1.png](https://community.atlassian.com/t5/image/serverpage/image-id/344929i151582D3099B96CF/image-size/large?v=v2&px=999 "Attachment 1.png")

![Attachment 2.png](https://community.atlassian.com/t5/image/serverpage/image-id/344930iD4675FFAFB55FE2A/image-size/large?v=v2&px=999 "Attachment 2.png")


author: Alex Medved _ConfiForms_
body: Well, You want a SOAP message to be produced, right?

Add a no format or code macro (inside the ConfiForms IFTTT macro body) and put your SOAP message in there

To reference values from ConfiForms fields use \[entry.field_name\] notations (not ConfiForms Field macros)


author: Alex Medved _ConfiForms_
body: Also, service URL in the webrequests is NEVER with the domain name (never an absolute URL), but a relative URL that is combined with the root path that you configure the web-service connection configuration


author: n_travaglini
body: Hi Alex

Thanks a lot! So I changed the url to /service.asmx?op=ImportCirrnet and added in the IFTTT Integration the following Code Block:

\<soapenv:Envelope xmlns:soapenv="<http://schemas.xmlsoap.org/soap/envelope/>" xmlns:web="<http://tempuri.org/>"\>  
\<soapenv:Header/\>  
\<soapenv:Body\>  
\<web:ImportCirrnet\>  
\<web:IdFachbereich\>\[entry.IdFachbereich\]\</web:IdFachbereich\>  
\<web:MassngepO\>\[entry.MassngepO\]\</web:MassngepO\>  
\<web:MassngetO\>\[entry.MassngetO\]\</web:MassngetO\>  
\<web:EreignisO\>\[entry.EreignisO\]\</web:EreignisO\>  
\<web:DatEreignis\>\[entry.DatEreignis\]\</web:DatEreignis\>  
\<web:aldLogin\>\[entry.aldLogin\]\</web:aldLogin\>  
\<web:aPwd\>\[entry.aPwd\]\</web:aPwd\>  
\</web:ImportCirrnet\>  
\</soapenv:Body\>  
\</soapenv:Envelope\>

However, I am still getting the following error:

Could not complete request (WebService Request) using configuration id = 081701e4-b4de-4ab3-862c-f17e1b7241b8. Requested to <https://www.cirrnet.ch/service.asmx/service.asmx?op=ImportCirrnet> has resulted in error. Response code = 500. Response contents: System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Web.Services.Protocols.HttpServerType..ctor(Type type) at System.Web.Services.Protocols.HttpServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean\& abortProcessing)

Really sorryy for the circumstances, I am not really able to solve it.

Thanks for your help


author: Alex Medved _ConfiForms_
body: Is that the URL you want to submit to?

<https://www.cirrnet.ch/service.asmx/service.asmx?op=ImportCirrnet>

?

Besides, you can see in the private ticket you have opened with us on what I was actually suggesting to do (using escapeXML function, for example)


author: Luis Pellacani
body: Hey [@n_travaglini](/t5/user/viewprofilepage/user-id/5574053)

Welcome to Atlassian Community.

The option to embed Confluence content outside our products is not currently available, due to the same-origin policy (set through the X-Frame-Options HTTP response header).

In case you opt to use the [ConfiForms](https://marketplace.atlassian.com/apps/1211860/confiforms-data-forms-workflows-for-confluence?tab=support&hosting=cloud) to achieve the desired results, we would suggest reaching them through their support channels:

* [Email vendor](mailto:vertuna@vertuna.com)
* [Submit a support request](https://wiki.vertuna.com/x/S4GW)

Based on the details you shared, it might be possible to integrate your requirements developing your own app to use inside Confluence. Our Developer Support team would be the best channel to further clarify your doubts on this matter. You can reach them on the channel below:

* [Developer Support](https://developer.atlassian.com/support)

Cheers,

Luis Pellacani

comments: author: n_travaglini
body: Hi Luis

Okey, great I will gladly reach out, if [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630)would not know how to solve it with the provided details.

Thank you guys a lot!


Tags: addon-com.vertuna.confluence.plugins.confiforms

cloud

confiforms

confluence-cloud