通常、400 Bad Request というエラーは、クライアント側に原因のあるエラーです。
主に、ブラウザで保持するCookieが壊れてしまった場合や、古いフォーマットがキャッシュされていて現状のCookieフォーマットと不整合が発生している場合などに発生します。
デスクトップブラウザを使用している場合には、インターネットオプションからCookieのキャッシュをクリアすることによって問題は解決しますが、BizRobo!の場合は”remove cookie(Cookie除去)”を実行しても現象は改善しません。
BizRobo!で本エラーが発生する場合の原因としては、以下2つのパターンが考えられます。
- HTTPレスポンスでサーバ側よりSet-Cookieの値をを取得できていない。
- HTTPリクエストでCookieが正しく設定できていない。
1.のケース:楽天管理画面(RMS)
楽天はRMSのメニュー画面で、各機能ごとセッション管理に必要なCookie情報をimgタグ内に組み込んだダミーのURIから取得する仕組みになっていますが、BizRobo!のデフォルト設定ではimgタグは読み込まない仕様となっているため、Set-Cookieが実行されず、メニュー画面から先のページへ移動しようとする際に400 Bad Requestが発生します。
→ 対応策
画面遷移するべき機能に紐づいたimgタグを読み込んで、Cookie をロボットの中に取り込むようにします。
It does appear that there is an issue with the cookies on the site. After spending a long time analyzing Fiddler captures, I was able to identify that some required cookies are only set when certain image URLs are loaded. By default, a robot won’t load all images, so the cookies weren’t being set. You’ll see the attached robot is configured to load image URLs containing the following strings:
item.rms.rakuten.co.jp/rms/mall/rsf/item/login
layout.rms.rakuten.co.jp/rms/mall/rsf/layout/loginThose match the image URLs that set the necessary cookies for the last two pages the robot loads. I suspect there may be others elsewhere on the site. You could just configure it to load all images, but that would make the robot much slower. You could also try configuring it to load all images that contain “/login?” which is part of both of these URLs — maybe it would be in the others. At any rate, the robot as you provided it to us now appears to load both of those pages in Design Studio the way they appear in IE8.
2.のケース:Twitter(ログイン画面)
ログイン画面表示時、Cookieが有効化どうかをチェックするために、JavaScriptの処理の中で、”名称=値” という形式に添わない “cookies_enabled” というcookieが生成されます。BizRobo!はこの値を ‘‘=cookies_enabled と、名称のないCookieとしてサーバに送信するため、サーバ側で不正なフォーマットのCookieとして判断され、400 Bad Request が発生します。
→ 対応策
Twitterにおける”cookies_enabled”の役割をソースから追っていくと、短にCookieが有効かどうかを確かめるためだけのために、試しにCookieに値が設定されている様であり、サーバとの通信のために必要とされるものではなさそうです。 Login ボタンを押してHTTP Requestを送り出す直前のStepで”cookies_enabled”を”remove cookie”しましょう。