0

I am trying to convert the C# code sample for making your first call to the PayPal API to VB using VS2015.

Specifically, I am trying to convert

var accessToken = new OAuthTokenCredential(config).GetAccessToken(); 

I have tried using

Dim accessToken = New OAuthTokenCredential(config).GetAccessToken() 

but I receive the following error:

Overload resolution failed because no accessible NEW can be called without a narrowing conversion. 

Does anyone have insight into this error or does anyone have a vb sample that I can refer to?

4
  • You need to specify the type in an As with the VB. Determine what type is returned by the GetAccessToken call and dimension your variable in VB accordingly, e.g. Dim token As AccessToken = new... Be careful with the names, VB is not case sensitive like C# so accessToken and AccessToken are the same name in VB. Commented Dec 28, 2016 at 14:48
  • Thanks for the reply, but I am not following you. I am aware of VB not being case sensitive. Are you stating that I should change the line to: Dim accessToken As New OAuthTokenCredential(config).GetAccessToken(). Commented Dec 28, 2016 at 14:58
  • He means Dim accessToken As String = New ... Commented Dec 28, 2016 at 15:01
  • I have changed to line to Dim accessToken As New OAuthTokenCredential(ClientID = ci, clientSecret:=cs). With ci and cs pulling values from the webconfig file and this has removed the previous error. However, now the next line of code - Dim apicontext As New APIContext(accessToken) is producing an error stating "Value of type 'OAuthTokenCredenital' cannot be converted to a string. Commented Dec 28, 2016 at 15:12

1 Answer 1

1

Try the following:

Dim AccessToken As String = New OAuthTokenCredential(Config).GetAccessToken() Dim aContext As APIContext = New APIContext(AccessToken) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.