Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Laurence Gillian 600 posts 1219 karma points
    May 10, 2013 @ 10:56
    Laurence Gillian
    0

    Contour RESTful API

    I'm sure I didn't dream this, but is there an API built in to Contour that can be posted to?

    E.g. you make a form, using nice plain old, sexy html. Use some JavaScript to hook into the submit event, serialize the form and then post it somewhere as JSON. Providing the URL matches the schema for the form, the data is posted and the API returns a little sigh of 'AWESOME!', hidden inside a 200 message.

    I'm aware of the Cultiv package which rocks, but I remember having a chat to someone at CodeGarden last year about this inbuilt functionality?

    This would make my Christmas come early!

    Lau :) 

  • Comment author was deleted

    May 13, 2013 @ 10:29

    Nope not yet, added it to the issue tracker and planned for next release

    http://issues.umbraco.org/issue/CON-361

    Ideally Contour should also handle to form creation based on the html form (so you don't have to manually map the html fields to contour fields)

     

  • Laurence Gillian 600 posts 1219 karma points
    May 13, 2013 @ 11:38
    Laurence Gillian
    0

    Thanks Tim, I'll use the Cultiv RestContour package for now. http://our.umbraco.org/projects/website-utilities/cultiv-restcontour ;

    Lau

  • keilo 568 posts 1023 karma points
    Nov 15, 2014 @ 14:19
    keilo
    0

    I am trying to accomplish the ajax form post (using jquery form) to Contour using 7.18. Obviously the contour field names are different so I cant simply post to a page containing the Contour form (which initially I thought would be simple, but then realized the field names are crypted)

    The Cultiv RestContour doesnt work as the /base/getContourForm/GetFormFields/ returns 500 Internal Server Error and no debug information available (nothing in tracelog or Windows Log, and i have enabled debug and errors in web.config.

    I understand the /base/ is no longer works in v7? I saw the post http://our.umbraco.org/forum/developers/extending-umbraco/46457-Umbraco-7-could-not-load-RestExtension?p=1

    I have the html forms designed so Im looking for a simple solution rather than customizing Contour/Views/ for each form and fields.Using AjaxBeginForm is not really what Im after as I have the html designed by other party and just want to do the ajax post to the Contour.

    So my question is how can I accomplish this simply in v7.1.8?

    Would appreciate any pointers.

  • keilo 568 posts 1023 karma points
    Nov 16, 2014 @ 15:46
    keilo
    0

    if one has an html form designed by third party, and would like to post the form to contour via ajax (jquery form?), what are the possible options using latest contour and Umb. 7.1.8 ?

    i cant seem to find a simple way to accomplish this. would greatly appreciate any feedback

  • Comment author was deleted

    Nov 17, 2014 @ 09:34
  • keilo 568 posts 1023 karma points
    Nov 17, 2014 @ 09:52
    keilo
    0

    Hi Tim 

    I came across that post while googling. In that implementation, one has to customize the Form.cshtml and re-create the html form.

    The main issue is I have the Html forms designed (some are modal popups or slide ins) by other party and I would like to direct their form submit via ajax to Contour backend (where i have the fields created to match).

    For that reason the Cultiv Rest Contour approach looked like the solution, i.e. no messing with the form html. But that no longer works with V7.

    Is there any other way to accomplish this in a Cultiv-Rest like approach?

    Basically I just want to send the form submission with jquery form plugin to a page that contains the Contour form embedded via macro. That would be adequate.

  • Comment author was deleted

    Nov 17, 2014 @ 10:06

    Ah I see, will you could use the cultiv restcontour code and turn it into an APIController

    http://our.umbraco.org/documentation/Reference/WebApi/

    It should just be a copy and paste job of the following code http://contourcontrib.codeplex.com/SourceControl/latest#Contour.Contrib/Cultiv.RestContour/SubmitContourForm.cs

  • keilo 568 posts 1023 karma points
    Nov 17, 2014 @ 10:12
    keilo
    0

    hi again Tim

    I am quite new to the WebApi... Looking a the SubmiContourForm.cs source code, it looks its beyond my current know-how..

    Would you be able to give me a basic sample that I can work with for the time being?

    that would be greatly appreciated

  • Comment author was deleted

    Nov 17, 2014 @ 10:13

    Sure I'm happy to create you a sample, not 100% sure it will work but we can give it a try

  • keilo 568 posts 1023 karma points
    Nov 17, 2014 @ 10:14
    keilo
    0

    Thank you!!! Xmas came early for me

  • Comment author was deleted

    Nov 17, 2014 @ 11:05

    ok got it working

    Please download the file https://www.dropbox.com/s/m3ozsjeuyxs2f8c/ContourRest.zip?dl=0

    Then extract that to your bin directory

    That will add a new api controller that has a single method, you can now post to /umbraco/api/Forms/CreateRecord

    You'll need to include a hidden field with the form id and then the rest of the fields are matched on the caption of the field in contour so if I have a form with a single field called name I can post to it like

    /umbraco/api/Forms/CreateRecord?formguid=0410bde0-275c-4b63-9877-567053182c4a&name=testing%20from%20api

    This will return a string that contains json so you'll need to parse the string first 

    Let me know how this works for you

     

  • keilo 568 posts 1023 karma points
    Nov 17, 2014 @ 12:05
    keilo
    0

    Hi Tim

    Dropped the contents of the zip  to the Bin folder and verified all files are there, no unlocking.

    I get 404 page not found when i hit the URL http://intranet/umbraco/api/Forms/CreateRecord or with test http://intranet/umbraco/api/Forms/CreateRecord?formguid=...&name=...

    am i missing something? config file etc?

     

  • Comment author was deleted

    Nov 17, 2014 @ 12:08

    Nope that should do the trick, which Umbraco version are you deploying to?

  • keilo 568 posts 1023 karma points
    Nov 17, 2014 @ 12:09
    keilo
    0

    Hi Tim

    its Umbraco version 7.1.8 assembly: 1.0.5394.16131

  • Comment author was deleted

    Nov 17, 2014 @ 12:18

    Make sure that the files aren't extracted in a sub dir but that the files are in the bin dir /bin

    so 

    /bin/ContourRest.dll
    /bin/ContourRest.dll.config
    /bin/ContourRest.pbd

  • Comment author was deleted

    Nov 17, 2014 @ 12:21

    This helped for me: extract the files on another location then the bin directory and then copy/paste them in place

    When I extract in the bin I also get 404

  • keilo 568 posts 1023 karma points
    Nov 17, 2014 @ 12:30
    keilo
    0

    Thanks Tim! Interestingly that worked, if i extract the file to temp folder then moved to bin (never get that one before). Great catch.

    I have managed to run a test, if the field name is one work it return json ok. If its with spaces like "Email Address" then it doesnt accept emailaddress (thought it will work like the customfieldtypes naming convention where space and upper/lower case is omitted) but only accepts if its html encoded like email%20address.

    Since these will be send from Form inputs, not sure if its the ideal approach to name form names with spaces (thinking about all the forms with special chars etc. - would it be better if it worked like the Custom field types (which we did for custom form\guidfolder\fieldtypename-without-spaces.cshtml ).

    What would be your suggestion to handling spaces and such in this case?

    many thanks!

  • Comment author was deleted

    Nov 17, 2014 @ 12:55

    Well you could make an update to the rest contour code... now it just looks for HttpContext.Current.Request[field.Caption]

    Project is available for download here https://www.dropbox.com/s/yp2dh2ikpd7jzn6/ContourRestProject.zip?dl=0 ;

  • keilo 568 posts 1023 karma points
    Nov 17, 2014 @ 13:00
    keilo
    0

    Will do. Downloading now.

    Million thanks! Much appreciated.

Please Sign in or register to post replies

Write your reply to:

Draft