Skip to content

[Bug]: RestSharp constructor not found #14

@rer145

Description

@rer145

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions