Jump to content

How to update fields after insert from url


infoweb
 Share

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

Recommended Posts

Hi There,

 

I'm trying to post data to a url which will then be imported to a web based application through an API.

 

I'm struggling to get this going using the insert from URL script step and using the following format for the URL:

 

httppost://myurl.com/post?sku=Products::sku&handle=Products::handle

 

Has anyone implemented this before and if so could you advise if I'm using the correct syntax for posting data to a URL?

 

Mark. 

Link to comment
Share on other sites

 

 

httppost://myurl.com/post?sku=Products::sku&handle=Products::handle

 

 

 

Should be something more like:

 

"httppost://myurl.com/post?sku=" & Products::sku & "&handle=" & Products::handle

 

It is a mix of literal string and values from fields.

  • Like 1
Link to comment
Share on other sites

Thanks for the feedback Wim

 

I made the changes to the insert url script step but I'm still getting error 3

 

At the moment it's a super simple script as I'm just trying to get the post part working.

 

Here's the script:

 

Go To Layout ["Product Details (Products)]

Insert from URL ["httppost://myurl.com/addproducts.php?sku=" & Products::sku & "&handle=" & Products::handle]

 

Last Error is error 3

 

Is there something I'm missing? All I'm trying to do is post the data to a URL so I can't see that I need anything else. the filemaker help doesn't go into much depth on this.

 

Mark

Link to comment
Share on other sites

Ok I experimented some more and it seems that a field must be selected even though I wasn't after a response. 

 

Not getting error 3 anymore - new error but sorting that one out.

Link to comment
Share on other sites

Well; that is what "insert…" means isn't it?

 

Insert into what?

 

Into the field you have selected in this script step; or into the field already selected by a script step or user action.

Which, in turn, also implies that the field you are inserting into must be on the layout, and must be a valid field for the current context.

Link to comment
Share on other sites

Thanks Bruce,

 

I was doing research on posting FM records using FM - and what I found only reference using insert from URL as a posting method - wasn't aware it required a response to be inserted into a field as mandatory.

 

I think I just expected the FM would have a way to post data to a URL natively on it's own, A bit like an export feature but posting to a URL.

 

Either way, Thank you both for your feedback, It's set me on the right track now.

Link to comment
Share on other sites

Filemaker does not have a HTTP POST method as such. You can post data as part of the Insert From URL[] and Import Records[] script steps. If you are not importing the response as records, then Insert From URL[] would make a better choice - and channeling the response to a field is good practice anyway, as it allows you to handle errors.

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

Thank you for your input.

 

I finally got this up and running. 

 

I'm able to post the data that I want to our web based POS system.

 

Now I'm trying to figure out how to handle the response. Will post a new topic to cover that though.

Link to comment
Share on other sites

Hi there,

 

Wondering if anyone could provide a little guidance for me.

 

We are posting product data from filemaker to a web based pos system, (through a custom API connector we created) and then receiving a response.

 

This response contains full product data from the pos system.

 

What I'm trying to achieve is that I update a number of fields in my filemaker record with selected data from the response.

 

I'm trying to figure out if this can be handled through XML ie. we can configure the response to be any any format we like. So if we inserted the response as filemaker xml could I then update certain fields with that?

 

I can't seem to find a way to interpret the xml when using "Insert from url" though.

 

Would appreciate it if anyone has any suggestions or pointers to guide me.

 

Mark 

Link to comment
Share on other sites

If you can get an XML response, you can import it directly, using the Import Records[] script step. You will need an XSLT stylesheet, though, to transform the response to Filemaker's FMPXMLRESULT grammar. See:

http://www.filemaker.com/help/13/fmp/en/html/non_toc.46.34.html#1079151

http://www.filemaker.com/help/13/fmp/en/html/import_export.17.18.html#1041831

Link to comment
Share on other sites

Thanks comment.

I'm trying to get my head around which way to do this now.

What I'm trying to do at the moment is create a new product in our pos system using an existing product in filemaker.

I'm posting the data from this new product record using 'insert from url' - that part is working.

The response I get back contains 4 values that I want to use to update 4 different fields in filemaker

What I'm trying to work out is the best way to format the response in order to update the fields.

I'm not sure whether using import will achieve what I'm after since I will only ever be doing this process on one single record at a time.m( the pos can only update a single record at a time)

I was thinking of formatting the response as a list then just extracting the values, but I was concerned that I wouldn't be able to easily check for errors.

I thought using xml and matching field names would cover some possible errors.

Link to comment
Share on other sites

The response I get back contains 4 values that I want to use to update 4 different fields in filemaker

 

Assuming that's 4 fields in the current record, and that the record is either the only record in the found set or that there is a matching value in the response, I would still go with using Import Records[]. Parsing XML by hand, using text functions, is not something I would willingly undertake.

Link to comment
Share on other sites

Got you. Basically using a script to find the current record, do an import, doing the http post as part of the import and parsing the response through a xml style sheet to update fields in the current record.

That makes sense. I get to work implementing that and see how it goes.

Thank you comment.

Link to comment
Share on other sites

This topic is 2949 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
 Share

×
×
  • Create New...

Important Information

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