function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mayank MohanMayank Mohan 

Einstein Vision API visualforce page code : Getting error "Error: Unknown property 'String.label' "

I am getting the above error while creating Visualforce page through code provided by Salesforce in Trailhead for Einstein.This was downlaoded from Github provided through link provided by Salesforce. Not sure what the error is and not able to resolve. Any help will be great. Stuck in the trailhead. 
The stage is for Trailhead Module : Get Smart with Salesforce Einstein  Quick Start: Einstein Image Classification: Create the Visualforce Page
 
<apex:page Controller="VisionController">
  <apex:form >
  <apex:pageBlock >
      <apex:image url="https://einstein.ai/images/generalimage.jpg">
      </apex:image>
      <br/>
      <apex:repeat value="{!AccessToken}" var="accessToken">
          Access Token:<apex:outputText value="{!accessToken}" /><br/>
    </apex:repeat>
      <br/>
      <apex:repeat value="{!callVisionUrl}" var="prediction">
          <apex:outputText value="{!prediction.label}" />:<apex:outputText value="{!prediction.probability}" /><br/>
      </apex:repeat>
  </apex:pageBlock>
<!--  <apex:pageBlock > -->
<!--      <apex:repeat value="{!callVisionContent}" var="prediction"> -->
<!--          <apex:outputText value="{!prediction.label}" />:<apex:outputText value="{!prediction.probability}" /><br/> -->
<!--    </apex:repeat> -->
<!--  </apex:pageBlock> -->
  </apex:form>
</apex:page>
Best Answer chosen by Mayank Mohan
NagendraNagendra (Salesforce Developers) 
Hi Mayank,

Please try below code:
<apex:page Controller="VisionController">
  <apex:form >
  <apex:pageBlock >
      <apex:image url="http://metamind.io/images/generalimage.jpg">
      </apex:image>
      <br/>
      <apex:repeat value="{!AccessToken}" var="accessToken">
          Access Token:<apex:outputText value="{!accessToken}" /><br/>
    </apex:repeat>
      <br/>
      <apex:repeat value="{!callVisionUrl}" var="prediction">
          <apex:outputText value="{!prediction.label}" />:<apex:outputText value="{!prediction.probability}" /><br/>
      </apex:repeat>
  </apex:pageBlock>
<!--  <apex:pageBlock > -->
<!--      <apex:repeat value="{!callVisionContent}" var="prediction"> -->
<!--          <apex:outputText value="{!prediction.label}" />:<apex:outputText value="{!prediction.probability}" /><br/> -->
<!--    </apex:repeat> -->
<!--  </apex:pageBlock> -->
  </apex:form>
</apex:page>
Note: I had the same issue - found an error in VisionController apex class line 6. Changed code from
where Title='einstein_platform'  to where Title='einstein_platform.pem 
Worked fine after that.

Please let us know if this helps.

Mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra
 

All Answers

NagendraNagendra (Salesforce Developers) 
Hi Mayank,

Please try below code:
<apex:page Controller="VisionController">
  <apex:form >
  <apex:pageBlock >
      <apex:image url="http://metamind.io/images/generalimage.jpg">
      </apex:image>
      <br/>
      <apex:repeat value="{!AccessToken}" var="accessToken">
          Access Token:<apex:outputText value="{!accessToken}" /><br/>
    </apex:repeat>
      <br/>
      <apex:repeat value="{!callVisionUrl}" var="prediction">
          <apex:outputText value="{!prediction.label}" />:<apex:outputText value="{!prediction.probability}" /><br/>
      </apex:repeat>
  </apex:pageBlock>
<!--  <apex:pageBlock > -->
<!--      <apex:repeat value="{!callVisionContent}" var="prediction"> -->
<!--          <apex:outputText value="{!prediction.label}" />:<apex:outputText value="{!prediction.probability}" /><br/> -->
<!--    </apex:repeat> -->
<!--  </apex:pageBlock> -->
  </apex:form>
</apex:page>
Note: I had the same issue - found an error in VisionController apex class line 6. Changed code from
where Title='einstein_platform'  to where Title='einstein_platform.pem 
Worked fine after that.

Please let us know if this helps.

Mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra
 
This was selected as the best answer
Sydney PedigoSydney Pedigo
Hey Nagendra, 

Thanks for posting an answer. I changed the code in the Predict visualforce step to the code you gave and then also tried correcting the error you spotted in the VisionController apex class but still am running into the same String.label error. 

If you have any advice I would love to hear. 
Cynthia Dery 7Cynthia Dery 7
Hi Sydney,

Have you been able to resolve this issue? I have the same error message! If you did, would you mind sharing you solution please?

Thank you!