I am pretty new to metadata API, I wonder how can I use metadata API to push some JSON metadata just like in jsForce(I successfully use jsForce in this way below in my local web app, but I am not sure how to use it in Lightnint web component):
I have a Lightning web component here, and I want to push the same metadata above here, but I do not know how to use similar metadata API(I do not have to use jsForce, any API does same thing will be fine):
Best Answer
Calling metadata API from LWC is not trivial as mentioned in Salesforce doc
As a workaround, I have used a VF page to generate a valid session Id which has API access.
I'm also using apex-mdapi open-source library to call metadata API
Sample code to create a Custom object using the Metadata API:
VF Page to generate API access enabled session Id(SessionId.page)
LWC Component
Apex Controller