Thread: Is creating a POST request for "Request Payload" data any different from form-data?

  1. #1
    Registered User
    Join Date
    Jun 2018
    Posts
    26

    Is creating a POST request for "Request Payload" data any different from form-data?

    C++ and libcurl are being used.




    How do I post "request payload" data?
    FYI I did ask this on stack overflow and cplusplus but I really need a response ASAP so I apologize in advance. And yes I have googled this however the examples I find seem to rely on the content type being "JSON", and it doesn't seem like that is the case here... where do I incorporate this webkit form boundary? Do I use the header libcurl functions to declare content type and then POST as is? It doesn't seem to work when I do that..

    My POST Request as is:

    Code:
    
        struct curl_httppost *datathree = NULL;
          struct curl_httppost *lastthree = NULL;
          
      
        curl_formadd(&datathree, &lastthree, CURLFORM_PTRNAME, "__VIEWSTATE", CURLFORM_PTRCONTENTS, "", CURLFORM_END);
        curl_formadd(&datathree, &lastthree, CURLFORM_PTRNAME, "ctl00$Pager", CURLFORM_PTRCONTENTS, "", CURLFORM_END);
        curl_formadd(&datathree, &lastthree, CURLFORM_PTRNAME, "__EVENTTARGET", CURLFORM_PTRCONTENTS, "ctl01$TC$BBD_ISSUE_RPTLink", CURLFORM_END);
        curl_formadd(&datathree, &lastthree, CURLFORM_PTRNAME, "__EVENTARGUMENT", CURLFORM_PTRCONTENTS, "", CURLFORM_END);
        curl_formadd(&datathree, &lastthree, CURLFORM_PTRNAME, "__EVENTVALIDATION", CURLFORM_PTRCONTENTS, "/wEWFAL+raDpAgLUy9G7AwLH6/qKCgKDnbntDgLH0vqJCAK5l5O1CQK42rCNBQKM4fNgAufEqeEHAoe/ytQJAvvQvU4C96OJow0C3YnIpgsC0a3s6A0CroaZiAYC28K51g4CpLPr/gcC46L8ww0Cq83cug4C0+nlwAwxZ4GmkToRQbkohSZ9EcEl40hsHA==", CURLFORM_END);
        curl_formadd(&datathree, &lastthree, CURLFORM_PTRNAME, "__LASTFOCUS", CURLFORM_PTRCONTENTS, "", CURLFORM_END);
    
    
    
    
    
    
        curl_easy_setopt(myHandle, CURLOPT_HTTPPOST, datathree);

    Code:
    Response Headers:
    
    
    Content-Type: text/html; charset=utf-8
    
    
    Request Headers:
    
    
    Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryG82cUGis7lmfHL19
    
    
    
    
    
    
    Request Payload:
    
    
      ------WebKitFormBoundaryG82cUGis7lmfHL19
        Content-Disposition: form-data; name="__VIEWSTATE"
    
    
    
    
        ------WebKitFormBoundaryG82cUGis7lmfHL19
        Content-Disposition: form-data; name="ctl00$Pager"
    
    
    
    
        ------WebKitFormBoundaryG82cUGis7lmfHL19
        Content-Disposition: form-data; name="__EVENTTARGET"
    
    
        ctl01$TC$BBD_ISSUE_RPTLink
        ------WebKitFormBoundaryG82cUGis7lmfHL19
        Content-Disposition: form-data; name="__EVENTARGUMENT"
    
    
    
    
        ------WebKitFormBoundaryG82cUGis7lmfHL19
        Content-Disposition: form-data; name="__EVENTVALIDATION"
    
    
        /wEWFAL+raDpAgLUy9G7AwLH6/qKCgKDnbntDgLH0vqJCAK5l5O1CQK42rCNBQKM4fNgAufEqeEHAoe/ytQJAvvQvU4C96OJow0C3YnIpgsC0a3s6A0CroaZiAYC28K51g4CpLPr/gcC46L8ww0Cq83cug4C0+nlwAzDcbaDFsCek7cLKaKs8kyafpbT3w==
        ------WebKitFormBoundaryG82cUGis7lmfHL19--

  2. #2
    Informer -Adrian's Avatar
    Join Date
    Jan 2013
    Posts
    820
    Can't you just use something simpler like Python? E.g. Requests?

  3. #3
    Registered User
    Join Date
    Jun 2018
    Posts
    26
    Quote Originally Posted by -Adrian View Post
    Can't you just use something simpler like Python? E.g. Requests?

    No, I have my reasons for using C++.

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    3,729
    Quote Originally Posted by aseagle View Post
    No, I have my reasons for using C++.
    Whether they are good or not.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  5. #5
    Registered User
    Join Date
    Jun 2018
    Posts
    26
    Quote Originally Posted by stahta01 View Post
    Whether they are good or not.

    Tim S.

    Can you all relax lol? I want to use C++. The question specifies C++. I want to learn how to do it in C++. Python is out of the equation. If you can't answer the question why bother?

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    3,729
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,607
    libcurl - curl_formadd()
    The very first line is
    This function is deprecated. Do not use! See curl_mime_init instead!
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Registered User
    Join Date
    Jun 2018
    Posts
    26
    Quote Originally Posted by stahta01 View Post

    I can ask whatever I want, wherever I want. These programming community rules were made by experienced programmers with a superiority complex (and a mental age of 12) that are trying to intimidate beginners into not asking questions on a public forum, which is very unfortunate and toxic. It's so silly to react this way to something on the internet. It's not that serious, relax and keep it moving. I am under a deadline and want an answer, my intentions are obviously not malicious or to be annoying. You were not born out of the womb knowing how to program, stop acting like it.

  9. #9
    Registered User
    Join Date
    Jun 2018
    Posts
    26
    @Salem Interesting, thanks for this.

  10. #10
    Registered User
    Join Date
    May 2009
    Posts
    3,729
    Quote Originally Posted by aseagle View Post
    I can ask whatever I want, wherever I want. These programming community rules were made by experienced programmers with a superiority complex (and a mental age of 12) that are trying to intimidate beginners into not asking questions on a public forum, which is very unfortunate and toxic. It's so silly to react this way to something on the internet. It's not that serious, relax and keep it moving. I am under a deadline and want an answer, my intentions are obviously not malicious or to be annoying. You were not born out of the womb knowing how to program, stop acting like it.
    I suggest you learn to be polite and ask smart questions!
    Or, you will likely end up being banned or ignored on many help forums.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  11. #11
    Registered User
    Join Date
    Jun 2018
    Posts
    26
    Quote Originally Posted by stahta01 View Post
    I suggest you learn to be polite and ask smart questions!
    Or, you will likely end up being banned or ignored on many help forums.

    Tim S.


    Ignore me then, it doesn't bother me. Nothing I said is grounds for banning me on any forum. I am not spamming one forum. If you are bothered by this you either don't have a day job or you need to seriously re-evaluate what is important to you in life. In terms of my question, it's fine. It's an appropriate question. I have done my research and I need further clarification. There's nothing wrong with that. Learn to pick your battles.

  12. #12
    Registered User
    Join Date
    Jun 2017
    Posts
    156
    I can ask whatever I want, wherever I want.
    That's true, however you might get more useful answers if you clearly tell us what you want to do in plain English.
    It also will help you to understand the problem if you write some pseudo code in plain English how to do this task so someone experienced in lib_curl can help you to translate into C++.
    It seems to me that you just copy some code somewhere without understanding it and expects others to fix it for you.

  13. #13
    Registered User
    Join Date
    Jun 2018
    Posts
    26
    Quote Originally Posted by OldGuy2 View Post
    That's true, however you might get more useful answers if you clearly tell us what you want to do in plain English.
    It also will help you to understand the problem if you write some pseudo code in plain English how to do this task so someone experienced in lib_curl can help you to translate into C++.
    It seems to me that you just copy some code somewhere without understanding it and expects others to fix it for you.
    This is part of my actual code, not something I directly copied from the internet. Listen, I am not a programmer by profession. Everybody who is learning does it through trying to modify similar examples that they find on the internet to suit their purpose. Through asking these types of questions it helps me understand the code. I don't expect others to fix it for me, I never even asked in my question for someone to fix it for me. Even if I did, if someone voluntarily does it what is it to you? I can't force anyone to fix anything. If you don't want to don't answer?

  14. #14
    Registered User
    Join Date
    May 2009
    Posts
    3,729
    If you do not wish to receive comments than do not post; I tried to help you. But, you seem to not be able to accept help except for very narrow answers to your question.

    You really need to learn how to ask smart questions and to ask them in the correct forums.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  15. #15
    Registered User
    Join Date
    Jun 2018
    Posts
    26
    Quote Originally Posted by stahta01 View Post
    If you do not wish to receive comments than do not post; I tried to help you. But, you seem to not be able to accept help except for very narrow answers to your question.

    You really need to learn how to ask smart questions and to ask them in the correct forums.

    Tim S.
    You did not answer the question, you made a snarky comment with a link to a page written by someone who takes themselves way too seriously, as you do. You need to learn how to answer in a smart way that actually addresses the question or to move on like a normal person with priorities in life and a day job. This is the correct forum, and my question is appropriate. You are not going to intimidate me into not asking the questions I have, deal with it.
    Last edited by aseagle; 07-20-2018 at 08:16 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 09-04-2013, 04:25 PM
  2. "Data Fork"/"Alternate Data Streams"
    By phantomotap in forum Tech Board
    Replies: 3
    Last Post: 08-06-2010, 11:01 AM
  3. HTTP Methods POST AND GET "DATA"
    By bhupesh.kec in forum C Programming
    Replies: 4
    Last Post: 06-05-2008, 12:35 PM
  4. "failed to grant minimum permission request"
    By namespace::me in forum Tech Board
    Replies: 4
    Last Post: 10-07-2006, 06:58 PM
  5. "Request For Comments"
    By sean in forum Tech Board
    Replies: 1
    Last Post: 01-05-2005, 05:08 AM

Tags for this Thread