Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: RestSharp constructor not found #14

Open
1 task done
rer145 opened this issue Aug 22, 2022 · 4 comments
Open
1 task done

[Bug]: RestSharp constructor not found #14

rer145 opened this issue Aug 22, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@rer145
Copy link

rer145 commented Aug 22, 2022

What happened?

Version 1.0.1 of the OneSignalApi throws an exception when sending a notification because it can't find a constructor in the RestSharp package.

Message: Method not found: 'Void RestSharp.RestRequest..ctor(RestSharp.Method)'.

StackTrace:
System.MissingMethodException: Method not found: 'Void RestSharp.RestRequest..ctor(RestSharp.Method)'.\r\n at OneSignalApi.Client.ApiClient.NewRequest(HttpMethod method, String path, RequestOptions options, IReadableConfiguration configuration)\r\n at OneSignalApi.Client.ApiClient.Post[T](String path, RequestOptions options, IReadableConfiguration configuration)\r\n at OneSignalApi.Api.DefaultApi.CreateNotificationWithHttpInfo(Notification notification, Int32 operationIndex)\r\n at OneSignalApi.Api.DefaultApi.CreateNotification(Notification notification, Int32 operationIndex)\r\n

Using RestSharp 108.0.1, I don't see a constructor in their code that matches the pattern of just taking in a Method.

I'm mixing a .NET Framework API with a .NET Standard Class Library, and the required packages are installed in both projects.

Code Snippet (inside the .NET Standard Class Library, called from the .NET Framework API):

var restApiKey = "......";
var Configuration = new OneSignalApi.Client.Configuration();
Configuration.BasePath = "https://onesignal.com/api/v1";
Configuration.AccessToken = restApiKey;
Configuration.ApiKey.Add("default", restApiKey);

var model = new OneSignalApi.Model.Notification(appId: AppId)
 {
    IncludeExternalUserIds = new List<string> { "..." },
    Name = "Test Message",
    ChannelForExternalUserIds = "push"
};

model.Contents = new OneSignalApi.Model.StringMap { En = "message contents" };

var api = new DefaultApi(Configuration);
var result = api.CreateNotification(model);
return !String.IsNullOrWhiteSpace(result.Id);

Steps to reproduce?

1. Create .NET Framework 4.8.1 API
2. Create .NET Standard 2.0 Class Library
3. Install packages: OneSignalApi 1.0.1, RestSharp 108.0.1, Newtonsoft.Json 13.0.1, JsonSubTypes 1.9.0, System.ComponentModel.Annotations 5.0.0 in both projects
4. Call the class library from the api
5. Get error

What did you expect to happen?

I expected the API to send a push notification message.

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@rer145 rer145 added the bug Something isn't working label Aug 22, 2022
@rer145
Copy link
Author

rer145 commented Aug 22, 2022

Related to #7. I downgraded RestSharp in both projects to 106.13.0 to match the OneSignalApi package and it works.

@rmariotti-choicelunch
Copy link

Are there plans to update this library to use the latest RestSharp (108+)?
RestSharp v107 was a large update and I have other code that also uses RestSharp v107+ features.

Much appreciated any roadmap or plans to use the "modern" RestSharp! Thanks,
Ryan

@webfletch
Copy link

Yes I would also like to know if you will be supporting the latest version of RestSharp, the latest version of Xero nuget package needs RestSharp 108.0.1 or greater but I cannot install it because OneSignal needs RestSharp below version 107.

@Jossec101
Copy link

Bump, still a big issue nowadays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants