You need to sign in to do that
Don't have an account?

Error Message for JSON: Content cannot be displayed: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at input location [1,2]
I am receiving this error message: Content cannot be displayed: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at input location [1,2]
This is for a visualforce page. Here is the Class:
And the VF Page is:
This is for a visualforce page. Here is the Class:
public class AccountShippingController { public String trackingnumber {get;set;} public String shipmentStatus {get;set;} public String shipperAddr {get;set;} public String consigneeAddr {get;set;} public AccountShippingController(ApexPages.StandardController stdController){ Account account =(Account)stdController.getRecord(); account = [SELECT Id, XPO_Tracking__c FROM Account WHERE Id =:account.Id]; String accountTracking = account.XPO_Tracking__c; String apiKey = 'XXXXXXXXXXXXXX'; String requestEndpoint = 'https://app.ltl.xpo.com/appjs/tracking/#/tracking'; requestEndpoint += 'details/' + accountTracking; requestEndpoint += '&APPID=' + apiKey; Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint(requestEndpoint); request.setMethod('GET'); HttpResponse response = http.send(request); if (response.getStatusCode() == 200) { Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody()); trackingnumber = String.valueOf(results.get('referenceNumbers')); Map<String, Object> shipmentStatusDtlsResults = (Map<String, Object>)(results.get('shipmentStatusDtls')); shipmentStatus = String.valueOf(shipmentStatusDtlsResults.get('shipmentStatus')); shipperAddr = String.valueOf(shipmentStatusDtlsResults.get('shipperAddr')); consigneeAddr = String.valueOf(shipmentStatusDtlsResults.get('consigneeAddr')); } else { ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, 'There was an error retrieving the information. Double check the Tracking Number, then contact a system administrator.'); ApexPages.addMessage(myMsg); } } }(I have removed the API key)
And the VF Page is:
<apex:page standardController="Account" extensions="AccountShippingController" showHeader="false" sidebar="false"> <apex:pageBlock title ="Shipping Information"> <apex:pageBlockSection> <apex:pageMessages/> <apex:outputText label="Shipping Status" value="{!shipmentStatus}"/> <apex:outputText label="Shipper Information" value="{!shipperAddr}"/> <apex:outputText label="Consignee Information" value="{!consigneeAddr}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:page>Any and all suggestions are welcome!
You get an XML response instead of a JSON response probably.
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint(requestEndpoint);
request.setMethod('GET');
request.setHeader('Content-Type', 'application/json');
request.setHeader('Accept','application/json');
HttpResponse response = http.send(request);