RageAgainstThePixel / com.utilities.rest

RESTful utilities for the Unity (UPM)
MIT License
22 stars 1 forks source link

PostAsync has a signature conflict #74

Closed SimonDarksideJ closed 6 months ago

SimonDarksideJ commented 6 months ago

Overview

From the example given in the ReadMe, this highlights a signature conflict for the PostAsync call between:

        public static async Task<Response> PostAsync(
            string query,
            string jsonData,
            Action<string> serverSentEventCallback,
            RestParameters parameters = null,
            CancellationToken cancellationToken = default)

And

        public static async Task<Response> PostAsync(
            string query,
            string jsonData,
            Action<Response> dataReceivedEventCallback,
            int? eventChunkSize = null,
            RestParameters parameters = null,
            CancellationToken cancellationToken = default)

Likely due to the defaults applied to the second method.

To Reproduce

Steps to reproduce the behavior:

  1. Create a new script

  2. Copy the Rest example from the readme

        var jsonData = "{\"data\":\"content\"}";
        var response = await Rest.PostAsync("www.your.api/endpoint", jsonData, eventData =>
        {
            Debug.Log(eventData);
        });
  3. Observe conflict error

image

Expected behavior

Examples should work out of the box, as should all method overloads.

StephenHodgson commented 6 months ago

wouldn't just adding the name of the parameter fix this?

      var jsonData = "{\"data\":\"content\"}";
      var response = await Rest.PostAsync("www.your.api/endpoint", jsonData, serverSentEventCallback: eventData =>
      {
          Debug.Log(eventData);
      });