1. Hello again :D

    i tryed using the Example Snippet in the Doc for POST-Request (so i customized nothing, in the first place)

    but its not working

    Code:
    [Oxide] 21:30 [Error] Failed to call hook 'PostRequest' on plugin 'MyPlugin v0.1
    .0' (InvalidCastException: Cannot cast from source type to destination type.)
    [Oxide] 21:30 [Debug]  at Oxide.Plugins.MyPlugin.DirectCallHook (System.String
    name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:
    0
      at Oxide.Plugins.CSharpPlugin.InvokeMethod (System.Reflection.MethodInfo metho
    d, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[]
     args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.Plugin.CallHook (System.String hookname, System.Object[]
     args) [0x00000] in <filename unknown>:0
    
     
  2. Wulf

    Wulf Community Admin

    Please provide the full error, not just the debug info, along with the code you are using exactly.
     
  3. Sorry.

    The Error that occurs
    Code:
    [Oxide] 21:30 [Error] Failed to call hook 'PostRequest' on plugin 'MyPlugin v0.1
    .0' (InvalidCastException: Cannot cast from source type to destination type.)
    

    Im using this exactly this Code:
    Code:
    [ChatCommand("post")]
      void PostRequest(IPlayer player, string command, string[] args)
      {
      // Set a timeout (in milliseconds)
      var timeout = 200f;  // Set some custom request headers (eg. for HTTP Basic Auth)
      var headers = new Dictionary<string, string> { { "header", "value" } };  webrequest.EnqueuePost("http://www.google.com/search?q=oxide", "param1=value1&param2=value2", (code, response) => PostCallback(code, response, player), this, headers, timeout);
      }  void PostCallback(int code, string response, IPlayer player)
      {
      if (response == null || code != 200)
      {
      hurt.BroadcastChat("Error: - Couldn't get an answer from Google for {player.Nickname}");
      return;
      }
      hurt.BroadcastChat("Google answered for " + player.Nickname + ": " + response);
      }
    
     
  4. Wulf

    Wulf Community Admin

    You can't use IPlayer in Hurtworld if your plugin isn't a Covalence plugin. The ChatCommand attribute is also not for Covalence plugins. Instead, use PlayerInfos and the appropriate parts for that. The Docs are being overhauled to support universal (Covalence) plugins.
     
  5. Okay:
    1. Thank you
    2. The API forces me to give a String as a Post Parameter.

    What if i want to POST a JSON-Object?
    I think simple casting is not a good solution or?
     
  6. Wulf

    Wulf Community Admin

    It is a simple HTTP POST, so whatever you can send via an HTTP POST you should be able to sent with it.