web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Portal Web API create ...
Power Pages
Answered

Portal Web API create contact and set account of newly created contact

(0) ShareShare
ReportReport
Posted on by 27

 

Hi Folks 

 

I am trying to create contact via Portal Web API + LIQUID code. I tried the below code to set the Account/Company of the newly created contact but I am getting 403.

 

// {% assign parentcustomerid = user.parentcustomerid.Id %}

 

var fname = $('#fname').val();
var lname = $('#lname').val();
var email = $('#email').val();
//var parentcustomerid = '{{parentcustomerid}}'
var dataObject = {
"emailaddress1": email,
"firstname": fname,
"lastname": lname,
"parentcustomerid_account":'{{parentcustomerid}}'

};
//"parentcustomerid_account":parentcustomerid
//"parentcustomerid":parentcustomerid

 
webapi.safeAjax({
type: "POST",
url: "/_api/contacts",
contentType: "application/json",
data: JSON.stringify(dataObject),
success: function (res, status, xhr) {
//print id of newly created entity record
console.log("entityID: " + xhr.getResponseHeader("entityid"))
}
});

 

I tried the  

 

noorahmad001_0-1619045165370.png

 

Categories:
  • Verified answer
    Fubar Profile Picture
    17 Super User 2026 Season 1 on at

    The association is usually a data bind

    "xxx_Customer_contact@odata.bind": "/contacts({{ user.id }})"

    The case of the letters in the fieldname may not all be lowercase (e.g. above when i defined Customer it had a caps 'C')

    Depending on the detail of the error the request-response in the browser usually has a bit more detail.

    Another trick to workout if its a fieldname issue is to try with and asterisk * for the field list in your Site Settings rather than listing out all the fields.

  • Noorahmad004 Profile Picture
    27 on at

    @Fubar thank you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Pages

#1
Mohsin Ali Profile Picture

Mohsin Ali 45

#2
sannavajjala87 Profile Picture

sannavajjala87 30 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 22 Super User 2026 Season 2

Last 30 days Overall leaderboard