我试图运行一个 shell 脚本,其中包含一个 curl 命令,其所需的标题如下。
counter=1
H1='Content-Type: application/json'
H2='Accept: application/json'
H3='Authorization: Bearer a0a9bb26-bb7d-3645-9679-2cd72e2b4c57'
URL='http://localhost:8280/mbrnd_new/v1/post'
while [ $counter -le 10 ]
do
TEST="curl -X POST --header $H1 --header $H2 --header $H3 -d @s_100mb.xml $URL"
echo $TEST
RESPONSE=`$TEST`
echo $RESPONSE
sleep 5
done
echo "All done"
Run Code Online (Sandbox Code Playgroud)
它给出了一个错误
curl: (6) Could not resolve host: application
curl: (6) Could not resolve host: Bearer
curl: (6) Could not resolve host: a0a9bb26-bb7d-3645-9679-2cd72e2b4c57
<ams:fault xmlns:ams="http://wso2.org/apimanager/security"><ams:code>900902</ams:code><ams:message>Missing Credentials</ams:message><ams:description>Required OAuth credentials not provided. Make sure your API invocation call has …Run Code Online (Sandbox Code Playgroud) 我在hackerrank.com做了一个简单的例子,要求我们返回给定日期的日期.例如:如果日期是08 05 2015(月份日),则应该返回星期三.
这是我为此任务编写的代码
public static String getDay(String day, String month, String year) {
String[] dates=new String[]{"SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY"};
Calendar cal=Calendar.getInstance();
cal.set(Integer.valueOf(year),Integer.valueOf(month),Integer.valueOf(day));
int date_of_week=cal.get(Calendar.DAY_OF_WEEK);
return dates[date_of_week-1];
}
Run Code Online (Sandbox Code Playgroud)
我的代码返回给定示例的'Saturday',它应该是'Wednesday'.对于2017年10月29日的当前日期,它将返回"星期三".有谁可以帮我解决这个问题?