You need to sign in to do that
Don't have an account?
Read timed out
Hello , I have a big problem. When i try to make a query in the rest api from apex salesforce, the VF return me a error: Read timed out .
This is my code:
httprequest req = new httprequest();
req.setEndpoint('https://cs4.salesforce.com/services/data/v22.0/query/?q=SELECT Id, (SELECT Id, StepStatus, Comments, OriginalActorId, CreatedDate FROM Steps where StepStatus!=\'Started\' AND StepStatus != \'Reassigned\' Order by CreatedDate Desc) FROM ProcessInstance Where TargetObjectId = \''+TargetObjectId+'\' Order by CreatedDate Desc');
req.setMethod('GET');
req.setHeader('Authorization', 'OAuth ' + token);
req.setTimeout(60000);
If I try to do a next request, work fine:
https://cs4.salesforce.com/services/data/v22.0/sobject/Case/XXXXX
But if I try to make a query, return me the timeout error, WHY?
Thanks.
You need to URLencode your query string.
All Answers
You need to URLencode your query string.
Hi Simon,
What do I do when I'm using curl to test the request? I get MALFORMED_QUERY error with this query:
curl https://treventforcedev-developer-edition.my.salesforce.com/services/data/v20.0/query?q=SELECT+Id,+Name+from+Contact+where+relationShipFieldId+=+'15 digit id' -H 'Authorization: OAuth 00Dd0000000cKfP!ASAAQMgiY.9R8SDGlZ8JX6b5WE5b1vxWXKTWIEbm9xvU1clK4j0d4_kxq1pEGtrbaSZ4nV1PSYUA8qesIawGxyvJvEFYuQoa' -H "X-PrettyPrint:1"
[ {
"message" : "\nwhere relationshipFieldId = a0Td0000000OfO6\n ^\nERROR at Row:1:Column:124\nunexpected token: 'a0Td0000000OfO6'",
"errorCode" : "MALFORMED_QUERY"
} ]
I tried all combinations of single and double quotes around the id, single and double quotes around the entire query, but keep getting the same error. Is there a way to filter using an ID field?
Thanks,
kpr
You need single quotes around the ID value. Use one of the soql/schema tools to test drive your query first (e.g. SoqlX, ApexExplorer, Force.com IDE etc)
Thanks Simon. That worked!