Jetzt verfügbar:  monatliche Berichte und BerichtsvorlagenMehr Infos

Ansteuerung API erzeugt 405er

Kommentare

7 Kommentare

  • Avatar
    Michael Netter

    Hi Mark,

    Thank you for sharing your 'InstantShare' idea, that's really cool.

    Regarding the 405:

    From your code snipped above, it's difficult to assess why a 405 is returned.

    To find the error, can you please provide the following information:

    1. Which endpoint are you calling that returns the 405? With endpoint I mean something like /v4/upload/{token}. 
    2. Which HTTP method (I assume 'POST') are you using to call the endpoint?
    3. When you call GET /v4/config/info/infrastructure, is the value of the field 's3EnforceDirectUpload' true or false?

    Best regards,

    Michael

    0
    Aktionen für Kommentare Permalink
  • Avatar
    Andreas Zirngibl

    Hi Mark,

    The problem was that the body was false formatted.

    We have quickly built a working example for getting the access token:

            private static string Login() {
                try {
                    // Login über OAUTH
                    string base64AuthInfo = Convert.ToBase64String(Encoding.ASCII.GetBytes(CLIENT_ID + ":" + CLIENT_SECRET));
                    Hashtable bodyList = new Hashtable();
                    bodyList.Add("grant_type", "password");
                    bodyList.Add("username", DRuser);
                    bodyList.Add("password", DRpwd);

                    HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(TokenUrl);
                    httpRequest.Method = "POST";
                    httpRequest.Headers["Authorization"] = "Basic " + base64AuthInfo;
                    httpRequest.ContentType = "application/x-www-form-urlencoded";

                    string body = "";
                    foreach (string key in bodyList.Keys) {
                        body += HttpUtility.UrlEncode(key) + "=" + HttpUtility.UrlEncode((string)bodyList[key]) + "&";
                    }
                    body = body.Substring(0, body.Length - 1); // remove trailing &

                    using (var streamWriter = new StreamWriter(httpRequest.GetRequestStream())) {
                        streamWriter.Write(body);
                    }

                    var httpResponse = (HttpWebResponse)httpRequest.GetResponse();
                    using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) {
                        return streamReader.ReadToEnd();
                    }
                }
                catch (Exception ex) {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }

                return "";
            }

    I hope this helps you.

    Best regards,
    Andreas

    1
    Aktionen für Kommentare Permalink
  • Avatar
    Mark Weißleder-Hennies

    Wow! Thank you very much for your support here :)
    I will try the code the next days and post my results here.

    Regards
    Mark

    0
    Aktionen für Kommentare Permalink
  • Avatar
    Mark Weißleder-Hennies

    Michael Netter

    Question 1: https://our.company.url/oauth/token

    Question 2: POST

    Question 3: Output

    "smsConfigEnabled": true,
      "mediaServerConfigEnabled": true,
      "s3DefaultRegion": "us-east-1",
      "s3EnforceDirectUpload": false,
      "isDracoonCloud": true,

    How I can enbale this and is this the cause of my issue? I've tried Andreas solution, but same issue > 405: Method not allowed

    Regards
    Mark

    0
    Aktionen für Kommentare Permalink
  • Avatar
    Michael Netter

    Hi Mark,

    thank you for your response. I now understand that you have an issue during the OAuth login. Is the problem solved with the code that Andreas provided?

    Best regards

    Michael

    0
    Aktionen für Kommentare Permalink
  • Avatar
    Mark Weißleder-Hennies

    Hi Michael, please see my post before your post. Is not solved now. The same issue before.

    Regards
    Mark

    0
    Aktionen für Kommentare Permalink
  • Avatar
    Michael Netter

    Hi Mark,

    too bad it does not work.

    Could you provide a minimal executable example that uses Andreas' solution that we can use for debugging?

    Best regards

    Michael

    0
    Aktionen für Kommentare Permalink

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.