One extra step, which I will ask in another topic, is how to use the logged in user to add the connection to his profile.
For anyone wanting to add a user with values using ajax, the basic code is this:
//execute this when user clicks the button
$('.button').click(function(event) {
// use the following data.
var data = {
field_37 : {
'email' : 'example@example.com', //new user email to be inserted in field 37
'label' : 'example'
},
field_41 : [55a1b550b2847881712431fe] //this is the id of the record you want to add to the new user inside of connection field_41
}
// insert the record
// this uses the PAGE API access to use an existing form to insert the record.
// replace XXX with your application ID
$.ajax({
url: "https://api.knackhq.com/v1/objects/object_6/records",
type: "POST",
headers: {"X-Knack-Application-Id": "xxx", "X-Knack-REST-API-Key": "xxx"},
data: data,
success: function(response) {
alert('Record Added!');
}
});
}); </pre><p> </p>