Create list REST Api v1.1

genexus

#1

I have this code in a Genexus app but i can’t create a list using REST API. I think my problem is the authentication token, but i don’t understand how to use it.
Can anybody help me?

//Get Twitter Token
&base64cred = StringToBase64.Udp(&credential)
&HttpClient.AddHeader('Authorization','Basic ' + &base64cred.Trim())
&HttpClient.AddHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8')
&HttpClient.AddString('grant_type=client_credentials')
&HttpClient.Secure = 1
&HttpClient.Host = 'api.twitter.com'
&HttpClient.Port = 443
&HttpClient.BaseUrl = '/'
&HttpClient.Execute('POST','oauth2/token')
&response = &HttpClient.ToString()
&TokenResponse.FromJson(&response)

//Create List
&HttpClient.AddHeader('Authorization','Bearer ' + &TokenResponse.access_token.Trim())
&HttpClient.AddHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8')
&HttpClient.Secure = 1
&HttpClient.Port = 443
&HttpClient.Host = 'api.twitter.com'
&HttpClient.BaseUrl = '/'
&HttpClient.Execute('POST','1.1/lists/create.json?name='+&ListaNombre.Trim()+"&mode=private&Description="+&ListaNombre.Trim())

The error is:

{“errors”:[{“code”:220,“message”:“Your credentials do not allow access to this resource.”}]}