force-rest-api icon indicating copy to clipboard operation
force-rest-api copied to clipboard

BUG with get knowledgeArticles

Open jinnguyen opened this issue 7 years ago • 3 comments
trafficstars

Hello,

I tried with /services/data/v40.0/support/knowledgeArticles via force-rest-api v40.0 and I get this issue: [{"errorCode":"MISSING_ARGUMENT","message":"Language has to be specified in HTTP header."}]

I search in Google and I know how to fix it: we need add header: Accept-language: en-US,en;q=0.9,vi;q=0.8

Document: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_knowledge_support_artlist.htm

I need its go to maven, b/c i include this client to my project via maven. Could u pls review and fix it and release to maven 0.0.41 ? tks!

jinnguyen avatar Mar 21 '18 09:03 jinnguyen

Which method in ForceApi are you using? getSObject or get()? It would be great if you can send a pull request with a proposed fix that includes a test.

jesperfj avatar Mar 21 '18 16:03 jesperfj

Hi, im using method get(), and seem like other method get same issue.

Actually it just need add 1 more header: header("Accept-language", "en-US,en;q=0.9,vi;q=0.8") like this:

return new ResourceRepresentation(this.apiRequest((new HttpRequest()).url(this.uriBase() + path).method("GET").header("Accept", "application/json").header("Accept-language", "en-US,en;q=0.9,vi;q=0.8")), this.jsonMapper);

jinnguyen avatar Mar 22 '18 01:03 jinnguyen

Btw, I think the best way is: the api should allow add headers to request

jinnguyen avatar Mar 22 '18 03:03 jinnguyen