Kevin-Bronsdijk / kraken-net

Official Kraken.io .Net client
https://kraken.io
GNU General Public License v2.0
19 stars 5 forks source link

Adds a proper field name so server would recognize data #22

Closed ZloeSabo closed 4 years ago

ZloeSabo commented 4 years ago

Description

Currently the optimize functionality is broken, because the api server requires passing credentials and other parameters in a "data" field. This change sets the field name, which fixes the issue.

Steps to Test or Reproduce

Checked upload with the old and with the new logic.

The client code I've used:

using System;
using System.Net;
using Kraken;
using Kraken.Http;
using Kraken.Model;

namespace kraken_net_cli
{
    class Program
    {
        static void Main(string[] args)
        {
            var connection = Connection.Create("your_key", "your_secret");
            var client = new Client(connection);
            var UploadResponse = client.OptimizeWait("./example.jpg",
                new OptimizeUploadWaitRequest()
                {
                    Lossy = true,
                });

            UploadResponse.Wait();

            Console.WriteLine(UploadResponse.Result.Body);
            if (UploadResponse.Result.StatusCode == HttpStatusCode.OK)
            {
                Console.WriteLine(UploadResponse.Result.Body.KrakedUrl);
            }
            else
            {
                Console.WriteLine("That went wrong.");
            }

        }
    }
}

Todos

ajtatum commented 4 years ago

I believe this is causing my image uploads to break. I have an automated function in Azure and it's very difficult to determine which images failed or not, so I have to reprocess the images... causing me to waste bandwidth.

ajtatum commented 4 years ago

I forked this branch and am using my own build and I'm still running into issues periodically when trying to resize image sets. The error I get is "(Unexpected character encountered while parsing value: <. Path '', line 0, position 0.)".

Kevin-Bronsdijk commented 4 years ago

Thanks for reporting the issues, I will merge this PR based on the test results. @ajtatum sounds like it tries to parse HTML instead of a JSON response, maybe the API is returning a 500 error. Let me see if it's possible to expose the response in a better way in order to understand and debug the problem.

ajtatum commented 4 years ago

@Kevin-Bronsdijk thanks. I really like Kraken and it's pretty much the only one that has a nice .NET SDK.