Apex REST callouts unit


これも良く目にする質問。

# Executing the 'getAnimalNameById' method on 'AnimalLocator' failed. Make sure the method exists with the name 'getAnimalNameById'

これまではこのエラーが出たら

回避するためには文字列結合を使う必要がある。
request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/'+id);

[Apex REST コールアウトのtrailチェックがバグってる件](https://qiita.com/K7AI5DYIxd/items/4a663101c4a12477d598)

だったんですが、最近はこれではないようです。

前からきになっていたのですが、Integer型をそのまま使っていること。
どうも、チェックロジックも変更してちゃんとString型にしないといけないよういなったのかもしれませんね。


request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/' + String.valueOf(id));

[Getting error on Apex REST Callout Challenge](https://trailblazers.salesforce.com/answers?id=9064S000000DnhrQAC)

以上でも解決しない場合
リモートサイト「https://th-apex-http-callout.herokuapp.com」を追加するとエラーが解決し、チャレンジに合格することができました。

Go to setup->Remote Site Setting->New. Then enter the detail and https://th-apex-http-callout.herokuapp.com/animals/id  this website in it. Save
 

[Cannot pass through the challenge in Apex REST Callouts unit](https://trailblazers.salesforce.com/answers?id=9064S000000Dy3C)

上記を試したのにエラー、何で解決したかは全くわからん。
[Following error occurs for Apex REST callouts. even though it does 100%](https://trailhead.salesforce.com/ja/trailblazer-community/feed/0D54S00000E9BOdSAN)

# No Remote Site named ‘animals_http’ was found with the correct Name, URL, and Description

+ [Apex Integration Services : Apex REST Callouts error - No Remote Site named ‘animals_http’ was found with the correct Name, URL, and Description](https://trailhead.salesforce.com/en/trailblazer-community/feed/0D54S00000G6AaVSAV)

:::note
リモートサイト名を間違っていたというオチでした。
:::

+ [??? No Remote Site named ‘animals_http’ was found with the correct Name, URL, and Description.](https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000Jgi1d)

:::note
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328136/3fc0770e-4b92-7d04-547f-8d693a996bfd.png)

https://developer.salesforce.com/forums/?id=9062I000000UfJoQAK
:::

+ [No Remote Site named ‘animals_http’ was found with the correct Name, URL, and Description.](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007UtcL0)


:::note
just Add both Remote site settings in your org in the previous module we perform this task  https://trailhead.salesforce.com/content/learn/modules/apex_integration_services/apex_integration_callouts

+ Add a Remote Site
   + Name: animals_http
   + Remote site URL: th-apex-http-callout.herokuapp.com
   + Description: Trailhead animal service: HTTP

+ Add a Remote Site
  + Name: animals_soap
  + Remote site URL: th-apex-soap-service.herokuapp.com
  + Description: Trailhead animal service: SOAP

https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000HECRvSAP
:::

# リモートサイトのURLが２つ？

[No Remote Site named ‘animals_http’ was found with the correct Name, URL, and Description.](https://trailhead.salesforce.com/en/trailblazer-community/feed/0D54S00000HktJHSAZ)

:::note
I found the issue. For some reason , you have to have both animals_http , animals_soap remote site settings created before checking REST excercise. Adding both of them fixed the issue.
:::

# エラー

+ [【未解決】UNKNOWN_EXCEPTION An unexpected error occurred. Please include this ErrorId if you contact support: 1345751719-421449 (1976928079).](https://trailhead.salesforce.com/trailblazer-community/feed/0D5KX000000mVIg)

+ [【未解決】Apex REST Callouts](https://trailhead.salesforce.com/trailblazer-community/feed/0D5KX000000mcxY0AQ)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328136/b9b3057f-a0b7-2afe-0e0f-1c67bd04c030.png)

既知の問題にあがっていますね。

https://issues.salesforce.com/issue/a028c00000zilvAAAQ/not-able-to-createupdate-staticresources-through-tooling-api-with-version-380-above