pin支付密钥位置中的groovy api

pin支付密钥位置中的groovy api,groovy,Groovy,我在pin.net.au中为pin支付做api,我遇到了一些错误,如您在底部看到的错误 `@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder'`,` version='0.5.0-RC2' ) import groovyx.net.http.* import groovyx.net.http.HttpResponseDecorator import groovyx.net

我在pin.net.au中为pin支付做api,我遇到了一些错误,如您在底部看到的错误

`@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder'`,` version='0.5.0-RC2' )
    import groovyx.net.http.*
    import groovyx.net.http.HttpResponseDecorator
    import groovyx.net.http.RESTClient
    import static groovyx.net.http.ContentType.*
    import groovyx.net.http.HttpResponseException
    import groovy.swing.SwingBuilder
    import javax.swing.JFrame
    import wslite.http.auth.*
    class Customers {

        Customers(){
            def rst = new RESTClient( 'https://test-api.pin.net.au/1/')
    rst.auth.basic 'mySecretKey',''
            def res = rst.post( path: 'customers'){
                type ContentType.XML
                xml {
                    cards{
                        email('pk_qTj9Umqmlf3o7lfa6F9nWw')
                        card[expiry_month]('12')
                        card[expiry_year]('2015')
                        card[cvc]('123')
                        card[name]('patrick pl')
                        card[address_line1]('23 frfds')
                        card[address_city]('Angeles')
                        card[address_postcode]('2009')
                        card[address_state]('ph')
                        card[address_country]('Philippines')

                    }
                }

            }

        }
        public static void main(String []args){

            new Customers()
        }
    }
当我运行代码时,错误是

   May 12, 2014 1:07:35 PM org.apache.http.impl.client.DefaultRequestDirector handleResponse
    WARNING: Authentication error: Unable to respond to any of these challenges: {}
    Caught: groovyx.net.http.HttpResponseException: Authorization Required
    groovyx.net.http.HttpResponseException: Authorization Required
        at groovyx.net.http.RESTClient.defaultFailureHandler(RESTClient.java:240)
        at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:475)
        at groovyx.net.http.HTTPBuilder.post(HTTPBuilder.java:335)
        at groovyx.net.http.HTTPBuilder$post.call(Unknown Source)
        at PinPayment.Customers.<init>(Customers.groovy:16)
        at PinPayment.Customers.main(Customers.groovy:39)
2014年5月12日下午1:07:35 org.apache.http.impl.client.DefaultRequestDirector HandlerResponse
警告:身份验证错误:无法响应以下任何挑战:{}
捕获:groovyx.net.http.HttpResponseException:需要授权
groovyx.net.http.HttpResponseException:需要授权
位于groovyx.net.http.RESTClient.defaultFailureHandler(RESTClient.java:240)
位于groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:475)
位于groovyx.net.http.HTTPBuilder.post(HTTPBuilder.java:335)
位于groovyx.net.http.HTTPBuilder$post.call(未知源)
在PinPayment.Customers.(Customers.groovy:16)
at PinPayment.Customers.main(Customers.groovy:39)
我怎样才能使代码能够运行的身份验证工作??
这里是文档的链接

文档表明它需要基本的HTTP认证

对Pin支付API的调用必须使用HTTP basic进行身份验证 身份验证,使用API密钥作为用户名,并使用空字符串 作为密码

因此:

def rst = new RESTClient( 'https://test-api.pin.net.au/1/' )
rst.auth.basic 'secretAPIKeyHereAsString', ''

我在这里找到了该特定api的正确代码https://test-api.pin.net.au/1/“)http.headers['Authorization']=“Basic”+“tWqZl0MHsg5nUQdB6czrDQ:”.getBytes('iso-8859-1')。encodeBase64()

密码应为空字符串,而不是空白。答案有用吗?将来,如果提供的答案不起作用,则不要仅使用提供的答案更新问题,在答案中提供一条注释,说明其不起作用的原因。我已经尝试过,先生,但出现了相同的错误..重置密码或重新创建新的API密钥,看起来您的帐户已锁定,API正在寻找需要回答的问题。这是我从错误消息中推断出来的。可能不正确。已完成,先生,但仍然出现相同的错误..:(