Consider:
<apex:page applyHtmlTag="true">
<apex:includeScript value="{!$Resource.Jsforce}"/>
<input type="file" id="input"></input>
<script type="text/javascript">
function ctrlRead(){
var selectedFile = document.getElementById('input').files[0];
var files = selectedFile.files;
var conn = new jsforce.Connection({ accessToken: '{!$Api.Session_Id}'});
conn.metadata.retrieve(files,function(error,ref) {
if (error) {
console.log("error");
}
else {
console.log(JSON.stringify(ref));
}
});
}
</script>
<apex:form>
<div>DEPLOYMENT TOOL</div>
<apex:commandButton onclick="ctrlRead();" value="Reterive" id="theButton"/>
</apex:form>
</apex:page>
I am trying to pass the file to the retrieving metadata API call using JSFORCE to extract the metadata. But I am getting the error
"INVALID_CROSS_REFERENCE_KEY: No packages or unpackaged specified"
How can I fix this problem?
Here is the next attempt and updated code.
I modified the code and tested it:
<apex:page applyHtmlTag="true">
<apex:includeScript value="{!$Resource.Jsforce}"/>
<input type="file" id="input"></input>
<script type="text/javascript">
function ctrlRead(){
var selectedFile = document.getElementById('input').files[0];
var files = selectedFile.files;
var para = {apiVersion:37.0,packageNames:null,singlePackage:true,specificFiles:files,unpackaged:files};
var conn = new jsforce.Connection({ accessToken: '{!$Api.Session_Id}'});
conn.metadata.retrieve(para,function(error,ref) {
if (error) {
console.log("error");
}
else {
console.log(JSON.stringify(ref));
}
});
}
</script>
<apex:form >
<div>DEPLOYMENT TOOL</div>
<apex:commandButton onclick="ctrlRead();" value="Reterive" id="theButton"/>
</apex:form>
</apex:page>
But now I am getting an error:
INVALID_CROSS_REFERENCE_KEY: More than 1 package retrieved with single package flag
This is the modified one i am getting success response
<apex:page applyHtmlTag="true">
<apex:includeScript value="{!$Resource.Jsforce}"/>
<input type="file" id="input"></input>
<script type="text/javascript">
function ctrlRead(){
var selectedFile = document.getElementById('input').files[0];
var files = selectedFile.files;
var para = {apiVersion:37.0,singlePackage:false,unpackaged:files};
var conn = new jsforce.Connection({ accessToken: '{!$Api.Session_Id}'});
conn.metadata.retrieve(para,function(error,ref) {
if (error) {
console.log("error");
}
else {
console.log(JSON.stringify(ref));
}
});
}
</script>
<apex:form >
<div>DEPLOYMENT TOOL</div>
<apex:commandButton onclick="ctrlRead();" value="Reterive" id="theButton"/>
</apex:form>
</apex:page>