Jump to content

create file to POST


Gillekes

This topic is 2741 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello everybody,

I have solution up and running and now I would like to send some data to a webservise using the REST method.

Got the authentication figured out which I thought would be the hard part and it wasn't.

Now I'm getting ready to send the data and I'm stuck! I need the data from a layout and the realted data from a portal. XML should be fine but I don't know where to start, how to create this xml with all the data and then in one way or another send it to the webservice.

If somebody could get me in de right direction...

 

I'm using FMP14

 

Thanks to all!

 

Link to comment
Share on other sites

The web service that you are connecting to normally dictates what the structure is of the XML or JSOn that it expects.  So start there.  Once you know that structure it really just becomes a text manipulation exercise.  Sometimes it is easy to store the 'template' for the XML or JSON payload in a preferences table with placeholders where you can substitute data in from your FM fields and records.

For the actual sending, you can either use the native "insert from URL" with the HTTPPOST prefix, or if you want more control you can use a plugin like the free BaseElements plugin.

 

Link to comment
Share on other sites

Hi Wim,

 

The API uses  WSDL. (https://login.keyinvoice.pt/API3_ws.php?wsdl)

The problem, for now, resides on the FM.

So I have a very hard time to understand how I can grab the XML data from my record (including the values from the related protal) to create a a POST with baseelements...

Step 1:

I'm trying to export the record to XML with the export records scriptstep. I'm trying to get this in a variable (I don't know if this is the right way to get the data?) but get an error from FMP14 "$keyincoice could not create on this disk. Use a different name, make more room on the disk, unlock it or use a different disk." The file I'm working on is a shared FM solution (not server)

Step 2: I haven't got to the next step yet.

 

Edited by Gillekes
Link to comment
Share on other sites

3 hours ago, Gillekes said:

how I can grab the XML data from my record (including the values from the related protal)

This is a little more complicated that it might seem at first.

First, you need to export your data as XML.

Next, you need to transform the exported XML from Filemaker's XML schema to the XML schema of the target application. You can do this at the same time you export the data, by specifying an XSLT stylesheet to be used during the export. If you're using the BE plugin, you can let the plugin do the transformation after the export is done. In both cases you will need a custom XSLT stylesheet file.

Finally, you will need to get the XML back into Filemaker. This is probably the most complicated part. You could import it natively into a global field (using 'update existing records' method)  - provided the XML contains no carriage returns. Or you could let the plugin read it for you - but then you will have to translate the FM export path into your OS path.

 

Edited by comment
Link to comment
Share on other sites

32 minutes ago, Gillekes said:

I'm trying to export the XML. Shoulf I do this to a file?, to a variable?

There is only one way to export data to XML (or any other format) and that is to a file - see:
http://www.filemaker.com/help/15/fmp/en/#page/FMP_Help%2Fexporting-data.html%23

 

You can use a variable to hold the path to the exported file - see:
http://www.filemaker.com/help/15/fmp/en/#page/FMP_Help%2Fcreating-file-paths.html%23wwconnect_header

This is useful when you want the script to export to a file first and do something with the exported file later - as is the case here.

 

 

Link to comment
Share on other sites

Hi Comment,

 

Thanks for the answer. Got the export working (withou the XSLT but i want to understand the whole procedure before starting the hard work of mapping the XLM).

I could export the file and have a file with a var for the path.

Now how would you send the post? Would the be element plugin be ok for this?

If so how would the script step look like? Should I use the object refresh script step?

Thanks

 

Link to comment
Share on other sites

1 hour ago, Gillekes said:

i want to understand the whole procedure before starting

I thought I gave you the whole procedure (at least as an outline) in my first post. That should get you to a point where you have the necessary XML either in a field (from which you can easily load it into a variable) or directly in a variable. I am afraid I cannot go any further than that, because I don't know what your web service requirements are.

Perhaps you need to start at the opposite end: write some example XML (by hand, if necessary), place it in a field and try to upload it to your web service. Once you succeed in that, you will know what your XML needs to look like, and how to upload it. Then you will only need to figure put how to produce such XML from your data - which shouldn't be too hard (and that's what my post was trying to explain).

Link to comment
Share on other sites

This topic is 2741 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.