CloudinaryDotNet icon indicating copy to clipboard operation
CloudinaryDotNet copied to clipboard

Proxy server not supported

Open MichelDaoust opened this issue 7 years ago • 4 comments

Hi, Thank you for you API but ...

Should return a good error (Proxy authentication) or better : Allow passing proxy info in the API. Now, the exception is a JSON token error, not really helpful.

Thank you.

MichelDaoust avatar Jan 31 '18 21:01 MichelDaoust

Hi @MichelDaoust. Could you please share some more information? what exactly do you expect to achieve and what's the exact issue you're currently facing (a reference to the code and a full error stacktrace would be very appreciated). Thanks!

roeeba avatar Feb 04 '18 13:02 roeeba

Hi @roeeba , I want to upload an image to Cloudinary.

In project CloudinaryDotNet.Core.csproj

If you look the result of the response in Api.Parse returned when you upload a file (from the CallAndParse function) you receive this HTTP reponse :

{StatusCode: 407, ReasonPhrase: 'authenticationrequired', Version: 1.1, Content: System.Net.Http.NoWriteNoSeekStreamContent, Headers:\r\n{\r\n Cache-Control: no-cache\r\n Date: Mon, 05 Feb 2018 20:16:14 GMT\r\n Proxy-Authenticate: NTLM\r\n Proxy-Authenticate: Basic realm="xxxxxxxx.com"\r\n Proxy-Connection: Keep-Alive\r\n Content-Length: 4076\r\n Content-Type: text/html\r\n}} Content [HttpContent]:{System.Net.Http.NoWriteNoSeekStreamContent}

So look the authenticationrequired and there is not valid JSON in the body.

So the result is when you get the JSON object from the response, you have this exception (because your HTTP response is now how you expect it) :

fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[0] An unhandled exception has occurred while executing the request Newtonsoft.Json.JsonReaderException: Error reading JToken from JsonReader. Path '', line 0, position 0. at Newtonsoft.Json.Linq.JToken.ReadFrom(JsonReader reader, JsonLoadSettings settings) at Newtonsoft.Json.Linq.JToken.Parse(String json, JsonLoadSettings settings) at CloudinaryDotNet.Api.Parse[T](Object response) at CloudinaryDotNet.Api.CallAndParse[T](HttpMethod method, String url, SortedDictionary2 parameters, FileDescription file, Dictionary2 extraHeaders) at CloudinaryDotNet.Cloudinary.Upload(ImageUploadParams parameters) at DatingApp.API.Controllers.PhotosController.<AddPhotoForUser>d__6.MoveNext() in C:\Users\michel.daoust\Documents\Demo\DatingApp\DatingApp.API\Controllers\PhotosController.cs:line 75 .... ....

thank you.

MichelDaoust avatar Feb 05 '18 20:02 MichelDaoust

Hi @MichelDaoust, thank you very much for sharing the details and apologize for not responding earlier. I've opened a ticket with our dev team. We'll do our best to address this issue as soon as we can.

roeeba avatar Mar 13 '18 06:03 roeeba

Hi @MichelDaoust. While it's still on our roadmap to support this in-house, you may find the following solution helpful - https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/network/defaultproxy-element-network-settings

roeeba avatar Feb 21 '19 09:02 roeeba