Android Question PostString Coinbase API error

Discussion in 'Android Questions' started by Multiverse app, Nov 9, 2018.

  1. Multiverse app

    Multiverse app Active Member Licensed User

    I've been trying to integrate the Coinbase API in my app for some time now.
    I was able to login and get access key with OAuth using webview.

    I am only having problems Sending money doc:

    Code:
    curl https://api.coinbase.com/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/transactions /
      -X POST \
      -H 
    'Content-Type: application/json' \
      -H 'Authorization: Bearer abd90df5f27a7b170cd775abf89d632b350b7c1c9d53e08b340cd9832ce52c2c' \
      -d '{
        "type""send",
        
    "to""1AUJ8z5RuHRTqD1eikyfUUetzGmdWLGkpT",
        
    "amount""0.1",
        
    "currency""BTC",
        
    "idem""9316dd16-0c05"
      
    }'

    my code:
    Code:
    'FOR PAYMENT
        'https://developers.coinbase.com/api/v2#send-money
        Dim CBJobSendPayment As HttpJob:CBJobSendPayment.Initialize("CBJobSendPayment", Me)
        
    Dim mapjg As Map:mapjg.Initialize
        mapjg.Put(
    "type""send")
        mapjg.Put(
    "to", strAccountID)
        mapjg.Put(
    "amount""0.000001")
        mapjg.Put(
    "currency""ETC")
        
    Dim jg As JSONGenerator:jg.Initialize(mapjg)

        CBJobSendPayment.PostString(
    "https://api.coinbase.com/v2/accounts/71ebec49-82b1-5ad1-9a8d-aabb054e82be/transactions", jg.ToString)
        CBJobSendPayment.GetRequest.SetHeader(
    "Content-Type""application/json")
        CBJobSendPayment.GetRequest.SetHeader(
    "Authorization""Bearer "&access_token)
        
    Wait For (CBJobSendPayment) JobDone(CBJobSendPayment As HttpJob)
        
    If CBJobSendPayment.Success Then
            
    Dim jp As JSONParser:jp.Initialize(CBJobSendPayment.GetString)
            
    Log(jp)
        
    Else
            
    Msgbox(CBJobSendPayment.ErrorMessage, "Error in payment!")
        
    End If
        CBJobSendPayment.Release
    I get the following error:
    Is it something that I am doing wrong in the code?
     
    Last edited: Nov 9, 2018
  2. Erel

    Erel Administrator Staff Member Licensed User

    You are not setting the content type correctly. It must be set with Job.GetRequest.SetContentType.
     
    Multiverse app likes this.
  3. Multiverse app

    Multiverse app Active Member Licensed User

    Works now, thanks
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice