• Resolved richardlm57

    (@richardlm57)


    Hello. I have a question because you mention this in the plugin FAQ: “Always use POST method and not GET to submit data, following url examples are only for demonstration purposes” but I’m trying it with the API and if I don’t set the parameters in URL, I’m getting an error. How can I pass these parameters with POST?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Ali Qureshi

    (@parorrey)

    You can use send data using POST method with jQuery or js or any standard form.

    Please check a jQuery POST call example here.

    https://guide.freecodecamp.org/jquery/jquery-ajax-post-method/

     
    <script>
    // Attach a submit handler to the form
    $( "#userForm" ).submit(function( event ) {
     
      // Stop form from submitting normally
      event.preventDefault();
     
      // Get some values from elements on the page:
      var $form = $( this ),
        user_id = $form.find( "input[name='user_id']" ).val(),
        url = "https://www.domain.com/api/user/get_avatar/?user_id="+user_id+"&type=thumb";
    
     
      // Send the data using post
      var posting = $.post( url, { s: term } );
     
      //Ajax Function to send a get request
      $.ajax({
        type: "POST",
        url: url,
        dataType:"jsonp"
        success: function(response){
            //if request if made successfully then the response represent the data
    
            $( "#result" ).empty().append( response );
        }
      });
      
    });
    </script>

    You can also use POSTMAN to send test REST API calls https://www.getpostman.com/downloads/

    or you can also use Advanced REST Client Extension for test api calls https://chrome.google.com/webstore/detail/advanced-rest-client/

    • This reply was modified 4 years, 11 months ago by Ali Qureshi.
    Thread Starter richardlm57

    (@richardlm57)

    I was (and I’m still) trying with Postman but always I’m getting this error: “You must include ‘username’ var in your request. “; this is happening when I try to test the “register” method. Also I’m sending the “insecure” parameter via GET because I’m testing in a local environment, I don’t know if it affects what I send with POST

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How can I send data using POST method?’ is closed to new replies.