在二级市场上购买票据的LendingClub.com API 500错误 [英] LendingClub.com API 500 Error for Buying Notes on Secondary Market

查看:114
本文介绍了在二级市场上购买票据的LendingClub.com API 500错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经能够与其他端点进行API请求,但是购买端点似乎根本无法工作.看来这是服务器错误,但我想我会在这里提出问题,以防万一我犯了一个粗心的错误.

I have been able to make API requests with other endpoints just fine, but the endpoint for making buys does not seem to work at all. It seems like it is a server error on their end, but I figured I would ask on here just in case I am making a careless mistake.

我编写了函数的多个版本,但这是一个版本:

I have written multiple versions of my function but this is one:

function getLCInfo($endpoint, $getData = false) {
  $api_url = "https://api.lendingclub.com/api/investor/";
  $verison = "v1";
  $account_id = "12345678";
  $ContentType = "application/json";

  $url = "$api_url$verison/accounts/$account_id/$endpoint/";

  if($getData) {
    $url .= "?" . urldecode(http_build_query($getData));

    echo $url;
  }


  $key = "aaaaaaaaaaaaaaaa99999999";

  $ch = curl_init();

  curl_setopt($ch, CURLOPT_URL, $url); 
  curl_setopt($ch, CURLOPT_HTTPHEADER,
              array('Authorization: ' . $key, 
                    'Content-type: ' . $ContentType , 
                    'Accept: ' . $ContentType, 
                    'X-LC-Application-Key: ' . $account_id));

  curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
  $output = curl_exec( $ch );

  curl_close( $ch );

  return json_decode($output);
}

这是他们的文档:

此子资源提供了投资者帐户的摘要.

This subresource provides a summary of the investor's account.

操作:获取

URL: https://api.lendingclub.com/api/投资者/v1/帐户/[投资者 id]/trades/

URL: https://api.lendingclub.com/api/investor/v1/accounts/[investor id]/trades/

URL参数:投资者ID-可以从帐户中获取 用户登录后,Lending Club网站上的摘要"部分.

URL Parameters: Investor Id - This can be obtained from the Account Summary section on Lending Club website when a user is logged in.

查询参数:无.

支持的格式:JSON购买说明请求

Supported Formats: JSON request for buy notes

请求/响应头:名称类型为空的描述 援助字符串否合伙人代表的投资者的ID 要求购买一张或多张笔记的钞票数组否一个的数组 或更多备注loanId字符串否其贷款的数字标识符 要求购买订单的注释编号字符串否的数字标识符 笔记的顺序noteId字符串否笔记的数字标识符 bidPrice字符串否以美元($)和美分为单位的正数值 表示笔记所需的买入价格示例请求:JSON —

Request/ Response Headers: NAME TYPE NULLABLE DESCRIPTION Aid String No The ID of the investor upon whose behalf the partner is requesting to buy one or more notes for notes Array No An array of one or more notes loanId String No Numeric identifier of the loan whose note requested for purchase orderId String No Numeric identifier of the order for the note noteId String No Numeric identifier of the note bidPrice String No Positive numeric value in dollars ($) and cents representing the buy price desired for the note Sample request: JSON —

{     "aid":70654,"notes":    [       {"loanId":3349795,"orderId":19979983,"noteId":5730626,"bidPrice":9.79},
  {"loanId":707414,"orderId":1369944,"noteId":4154191,"bidPrice":23.84},
  {"loanId":1076461,"orderId":2133757,"noteId":7827843,"bidPrice":34.45}

] }

样本响应-

{     buyNoteConfirmations:       [ 3 ] :         {           loanId:  3349795            noteId:  5730626            bidPrice:  9.79 
      outstandingAccruedInterest:  null           outstandingPrincipal:  null 
      yieldToMaturity:  null              executionStatus:            [ 1 ] :   "

NOTE_DOES_NOT_EXIST} 1:{{loanId:707414 noteId:4154191 bidPrice:23.84 excellentAccruedInterest:空未偿本金:空 yieldToMaturity:null执行状态:[1]: NOTE_NOT_AVAILABLE } 2:{{loanId:1076461 noteId:7827843 bidPrice:34.45 excellentAccruedInterest:空未偿本金:空yieldToMaturity:空执行状态:[1] 0: SUCCESS_PENDING_SETTLEMENT }

NOTE_DOES_NOT_EXIST " } 1: { loanId: 707414 noteId: 4154191 bidPrice: 23.84 outstandingAccruedInterest: null outstandingPrincipal: null yieldToMaturity: null executionStatus: [ 1 ] : " NOTE_NOT_AVAILABLE " } 2: { loanId: 1076461 noteId: 7827843 bidPrice: 34.45 outstandingAccruedInterest: null outstandingPrincipal: null yieldToMaturity: null executionStatus: [ 1 ] 0: " SUCCESS_PENDING_SETTLEMENT " } }

这是我在邮递员中进行测试时发生的情况 发布数据:

This is what happens when I test in Postman POSTing data:

POST /api/investor/v1/accounts/87308218/trades/ HTTP/1.1
Host: api.lendingclub.com
Authorization: aaaaaaaaaaa111111
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 68d283a6-08f0-6789-3542-3a1baa554ce7

{
    "aid":70654,"notes":
    [
        {"loanId":3349795,"orderId":19979983,"noteId":5730626,"bidPrice":9.79}, 
        {"loanId":707414,"orderId":1369944,"noteId":4154191,"bidPrice":23.84}, 
        {"loanId":1076461,"orderId":2133757,"noteId":7827843,"bidPrice":34.45}
    ]
} 

并且我尝试按照他们的文档所述使用GET.

and I tried to use GET like their documentation says.

GET /api/investor/v1/accounts/87308218/trades/?aid=12345678&notes[0][loanId]=17213188&notes[0][orderId]=25300948&notes[0][noteId]=48382917&notes[0][bidPrice]=6.77&notes[1][loanId]=17213188&notes[1][orderId]=25300943&notes[1][noteId]=48382538&notes[1][bidPrice]=6.77 HTTP/1.1
Host: api.lendingclub.com
Authorization: aaaaaaaaaaa111111
Cache-Control: no-cache
Postman-Token: b34cb60b-91ea-c82e-349f-d395b01b1dc0

提前谢谢!

推荐答案

我知道了!事实证明LendingClub在其文档中的信息不正确(非常令人沮丧!).

I figured it out! Turns out LendingClub had incorrect info on their documentation (super frustrating!).

我的解决方案是将Operation改为POST而不是GET,并且端点不正确.

My solution was to change the Operation to POST instead of GET and the endpoint was incorrect.

它们具有URL: https://api.lendingclub.com/api /investor/v1/accounts/[investor id]/trades/,它应为URL: https://api.lendingclub.com/api/investor/v1/accounts//trades/buy (这实际上更有意义,因为其API的销售端点以/trades/sell结尾.

They have URL: https://api.lendingclub.com/api/investor/v1/accounts/[investor id]/trades/, it should be URL: https://api.lendingclub.com/api/investor/v1/accounts//trades/buy (which actually makes much more sense since their API's sell endpoint ends with /trades/sell.

我希望LendingClub的一些开发人员可以阅读并编辑API文档,我敢肯定我并不孤单!

I hope some developer at LendingClub reads this and edits the API documentation, I'm sure I'm not alone with this!

这篇关于在二级市场上购买票据的LendingClub.com API 500错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆