PUT method to update contact is failing
I am trying to update the contact details.
this.data =JSON.parse(data);
var contactId = this.data.Id;
let userurl = 'https://api.wildapricot.org/v2/Accounts/' + accountid + '/Contacts/' +contactId;
console.log("efore put call", userDetails);
console.log("efore put call stringified", JSON.stringify(userDetails));
let bodyString = JSON.stringify(userDetails);
this.http.put(userurl, bodyString, {headers:headers})
.map(res => <User>(res.json()))
.subscribe(userAuth => {
// we've got back the raw data, now generate the core schedule data
// and save the data for later reference
this.userData = userAuth;
console.log('get user details', userAuth);
resolve(this.userData);
},
err => {
console.log("error", err);
});
});
that is my put code.. as your can see I am sending the body text as stringbut this gives me an error.
But when I do the samle as
var bodyString = "Id=33053793&FirstName=test&=";
like this. it works but doing the similar formatting at a form level and also passing values for field values may not be a practical option.
Thanks
-
Bala commented
Thanks @Matthew Thomure... looks like its working now..
-
Matthew Thomure commented
Hello, I just happened upon this but I think I might be able to help. According to your sample data, it looks like you want a query string, not a JSON string.
Why don't you try:
let bodyString = $.param(userDetails);
See JSFiddle: