Author Topic: Buy notes on the secondary market with API get UnAuthorized error  (Read 149 times)

dx2018

  • Newbie
  • *
  • Posts: 2
    • View Profile
I tried REST api to buy note, but always fails with UnAuthorized error. Is there any additional steps I need to go through before using any secondary market API?

Here is what I did:

request ------------------------

POST https://api.lendingclub.com/api/investor/v1/accounts/[myid]/trades/buy/ HTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0
Authorization: [mytoken]
Content-Type: application/json
Accept: application/json
Host: api.lendingclub.com
Content-Length: 139
Expect: 100-continue

{
    "aid":[myid], "notes":
    [
        {"loanId":130087470, "orderId":204339626, "noteId":180152509, "bidPrice":0.01}
    ]
}

response -------------------------

HTTP/1.1 401 Unauthorized
Content-Type: application/json
Content-Length: 67
Date: Wed, 28 Nov 2018 21:40:31 GMT
Set-Cookie: XXXXX
Vary: Accept-Encoding

{"errors":[{"code":"unauthorized","msg":"Operation not allowed."}]}

I also try to include X-LC-Application-Key, but it doesn't help

request --------------------------

POST https://api.lendingclub.com/api/investor/v1/accounts/[myid]/trades/buy/ HTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0
Authorization: [mytoken]
X-LC-Application-Key: [myid]
Content-Type: application/json
Accept: application/json
Host: api.lendingclub.com
Content-Length: 139
Expect: 100-continue

{
    "aid":[myid], "notes":
    [
        {"loanId":130087470, "orderId":204339626, "noteId":180152509, "bidPrice":0.01}
    ]
}

response -------------------------

HTTP/1.1 401 Unauthorized
Content-Type: application/json
Content-Length: 67
Date: Wed, 28 Nov 2018 21:40:31 GMT
Set-Cookie: XXXXX
Vary: Accept-Encoding

{"errors":[{"code":"unauthorized","msg":"Operation not allowed."}]}

I also tried to access LC directly with the token, it works

request: ------------------------

GET https://api.lendingclub.com/api/investor/v1/accounts/[myid]/availablecash/ HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
Authorization: [mytoken]
X-LC-Application-Key: [myid]
Content-Type: application/json
Accept: application/json
Host: api.lendingclub.com
Accept-Encoding: gzip
Connection: Keep-Alive

response: ----------------------

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 47
Date: Wed, 28 Nov 2018 21:47:02 GMT

{"investorId":[myid],"availableCash":[mycash]}



liquidp2p_dev

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Buy notes on the secondary market with API get UnAuthorized error
« Reply #1 on: November 28, 2018, 10:53:18 PM »
Hi dx2018,

In order to use the secondary market API you need to request secondary market API access in addition to regular secondary market access.

The company that I work for, Liquid P2P, has quick instructions on how to sign up for secondary market API access here:

https://www.liquidp2p.com/getting-started#faq9

Hope this helps.

dx2018

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Buy notes on the secondary market with API get UnAuthorized error
« Reply #2 on: November 29, 2018, 02:52:31 PM »
Thanks a lot liquidp2p_dev,

This's the exact inform I am looking. It solved my issue. Btw, your instruction page is a bit old, my case is auto approved.

Thanks Again

liquidp2p_dev

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Buy notes on the secondary market with API get UnAuthorized error
« Reply #3 on: November 29, 2018, 05:28:01 PM »
I'm glad we were able to help. Happy trading!