我正在使用API订购SoftLayer VM。此外,设置用户元数据值。 我一直在使用" softlayer-api-client-0.2.2.jar"调用各种API。
setUserMetadata之前工作正常。但是几天之后就失败了。 这个API最近有变化吗?上面的jar文件版本是否正确?
setUserMetadata API提供以下错误 -
线程中的异常"线程-2" com.softlayer.api.ApiException $ Internal:SoftLayer_Virtual_Guest_Strategy_Behavior_Standard :: setUserMetadata未实现。(代码:SoftLayer_Exception_NotImplemented,status:500)
请帮助解决此问题。谢谢!
答案 0 :(得分:0)
我很抱歉,我能够通过SoftLayer API Client for Java设置用户元数据,这里是一个java脚本,试试这个,如果你继续遇到问题请告诉我。确保使用客户端的主分支。
脚本:
package com.softlayer.api.VirtualGuest;
import com.softlayer.api.ApiClient;
import com.softlayer.api.RestApiClient;
import com.softlayer.api.service.virtual.Guest;
import java.util.ArrayList;
import java.util.List;
/**
* This script sets the data that will be written to the configuration drive.
*
* Important Manual Page:
* http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/setUserMetadata
*
* @license <http://sldn.softlayer.com/article/License>
* @authon SoftLayer Technologies, Inc. <sldn@softlayer.com>
* @version 0.2.2 (master branch)
*/
public class SetUserMetadata {
/**
* This is the constructor, is used to set user metadata
*/
public SetUserMetadata() {
// Declare your SoftLayer username and apiKey
String username = "set me";
String apiKey = "set me";
// Create client
ApiClient client = new RestApiClient().withCredentials(username, apiKey);
Guest.Service guestService = Guest.service(client, new Long(206659875));
// Setting the medatada
String metadataTest = "test1RcvRcv";
List<String> metadata = new ArrayList<String>();
metadata.add(metadataTest);
try {
boolean result = guestService.setUserMetadata(metadata);
} catch (Exception e) {
System.out.println("Error: " + e);
}
}
/**
* This is the main method which makes use of SetUserMetadata method.
*
* @param args
* @return Nothing
*/
public static void main(String[] args) {
new SetUserMetadata();
}
}
<强>参考文献:强>