[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HTTP API - EXAMPLE8 - HTTP/1.1 500 Internal Server Error



   Thanks all and Scott. The code Scott given worked perfectly.

   On Thu, Jun 9, 2011 at 2:26 PM, Scott Klement <[1]sk@xxxxxxxxxxxxxxxx>
   wrote:

     Hello,
     Most likely, you are misformatting the data you're sending. That's
     the
     cause of 99% of the '500' errors. Since we haven't seen it, or a
     debug
     log, or even the response message from the server (if there is one)
     it's
     really hard for us to help you.
     Understand this:  Every web service is different. Just because you
     think
     you know what to send, doesn't me that *we* do, or that we know
     what
     you're doing wrong.
     The curl example is helpful.  It gives us a lot more information
     than we
     had before -- but it doesn't tell us what you *are* doing, it only
     tells
     us what you SHOULD BE doing.
     The curl example was obviously written for a Unix shell script. The
     syntax used in Unix is much, much, different from the same syntax
     in RPG.
     You say you're using EXAMPLE8 -- that's an example that I've
     scheduled
     to be removed from HTTPAPI because it's no longer needed (there are
     easier ways to POST a file than dumping it to a user space these
     days..
     the user space technique is from a very old version of HTTPAPI.
     Though,
     it does still work.)
     But, your curl example doesn't send a file!  It sends a string.  So
     it's
     really not all that similar, is it?   And since the curl example is
     in
     Unix shell script syntax, you'd have to understand how to format
     your
     file correctly, removing the characters that would normally be
     handled
     by the shell.  How can we possibly tell if you did that correctly?
      Mind
     reading?
     If I were trying to do the same thing in RPG with HTTPAPI, I'd
     probably
     end up with something like this:
          D data            s           1000a   varying
          D rc              s             10i 0
          D tempfile        s             50a   varying
           /free
              data =
                  '{ +
                    ''event_type'':''trigger'', +

                  ''description'':''Server www15 running low on memory'',
   +
                  ''service_key'':''e93facc04764012d7bfb002500d5d1a6'', +
                  ''incident_key'':''frontend-low-free-memory'', +
                  ''payload'' : { +
                     ''server_name'': ''www15'',+
                     ''memory_usage'': ''98%'',+

                       ''threshold'': 90 +
                    } +
                  }';
              http_setCCSIDs(1208: 0);
              tempfile = http_tempfile();
              rc = http_url_post( '[2]https://events.pagerduty.com/+
                                   generic/2010-04-15/create_event.json'
                                : %addr(data) + 2
                                : %len(data)
                                : tempfile
                                : HTTP_TIMEOUT
                                : HTTP_USERAGENT
                                : 'application/json' );
              if (rc <> 1);
                 http_crash();
              endif;
     But, bear in mind that there are potential CCSID problems with the
     {}
     characters... it might be a good idea to use Unicode instead of
     EBCDIC
     for those characters.

   On 6/9/2011 11:07 AM, Narasimha Reddy wrote:
   >
   >     I want to post a file to my vendor link. I used EXAMPLE8 to do
   this. I
   >     have to change only file name and http link to use it rite !! I
   am
   >     also in touch with my vendor about this error.
   >
   >
   >
   >     Can you help me if I just want to post stream of data to a given
   link,
   >     which is the good example I can use as model program ?
   >
   >     Here is a sample using curl, I would like to do the same from
   iSeries.
   >
   >
   >
   >     curl -X POST

     >
     [1][3]https://events.pagerduty.com/generic/2010-04-15/create_event.
     json

   >     -d "{ \
   >     'event_type':'trigger', \
   >     'description':'Server www15 running low on memory', \
   >     'service_key': 'e93facc04764012d7bfb002500d5d1a6', \
   >     'incident_key':'frontend-low-free-memory', \
   >     'payload' : { \
   >     'server_name': 'www15', \
   >     'memory_usage': '98%', \
   >     'threshold': 90 \
   >     } \
   >     }"
   >
   >
   >
   >
   >     On Thu, Jun 9, 2011 at 11:28 AM, Mike Krebs

   >     <[2][4]mkrebs@xxxxxxxxxxxxxxxxxx>  wrote:
   >
   >       500 error comes from the server but is probably caused by what
   you
   >       are sending. What does the web page require and what did you
   post?
   >       Look at the page that does the post and decipher the
   parameters.
   >       If you only changed two lines, it probably isn't going to work
   very
   >       well.
   >
   >     -----Original Message-----

     >     From: [3][5]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
     >     [mailto:[4][6]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On
     Behalf Of

   >     Narasimha Reddy
   >     Sent: Thursday, June 09, 2011 10:03 AM
   >     To: HTTPAPI and FTPAPI Projects
   >     Subject: HTTP API - EXAMPLE8 - HTTP/1.1 500 Internal Server
   Error
   >     Hello,
   >     I have copied Example8 program to post the file. But I am
   getting
   >     following
   >     Error.
   >     *HTTP/1.1 500 Internal Server Error  *
   >     Is it Error from the server or from the code I modified ? Can
   some one
   >     explain this error ? I am very new to these concepts.
   >     I modified 2 lines Example8 as below:
   >     eval      stmf = '/home/trigger1.json'
   >     .

     >     eval      rc=http_url_post('[5][7]http://events.pager'+
     >                  '[6][8]duty.com/generic/2010-04-15/'+

   >                  'create_event.json':
   >                   p_data: st_size:
   >                   '/httptest.html')
   >     /home/trigger1.json contains following data
   >     {
   >      "service_key": "3397ab606eba012eae1812313d009e57",
   >      "incident_key": "HTTPAPI01",
   >      "event_type": "trigger",
   >      "description": "Testing Trigger from HTTP API by Reddy by Reddy
   "
   >     }
   >     I want to post this data to

     >
     [7][9]http://events.pagerduty.com/generic/2010-04-15/create_event.j
     son

   >     --
   >     Narasimha Reddy
   >
   >
   -------------------------------------------------------------------
   >       ----
   >       This is the FTPAPI mailing list.  To unsubscribe, please go
   to:

     >       [8][10]http://www.scottklement.com/mailman/listinfo/ftpapi
     >
     -------------------------------------------------------------------
     >       ----
     >
     >     --
     >     Narasimha Reddy
     >
     > References
     >
     >     1.
     [11]https://events.pagerduty.com/generic/2010-04-15/create_event.js
     on
     >     2. mailto:[12]mkrebs@xxxxxxxxxxxxxxxxxx
     >     3. mailto:[13]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
     >     4. mailto:[14]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
     >     5. [15]http://events.pager/
     >     6. [16]http://duty.com/generic/2010-04-15/'+
     >     7.
     [17]http://events.pagerduty.com/generic/2010-04-15/create_event.jso
     n
     >     8. [18]http://www.scottklement.com/mailman/listinfo/ftpapi

   >
   >
   >
   >
   >
   ----------------------------------------------------------------------
   -
   > This is the FTPAPI mailing list.  To unsubscribe, please go to:
   > [19]http://www.scottklement.com/mailman/listinfo/ftpapi
   >
   ----------------------------------------------------------------------
   -
   ----------------------------------------------------------------------
   -
   This is the FTPAPI mailing list.  To unsubscribe, please go to:
   [20]http://www.scottklement.com/mailman/listinfo/ftpapi
   ----------------------------------------------------------------------
   -

   --
   Narasimha Reddy

References

   1. mailto:sk@xxxxxxxxxxxxxxxx
   2. https://events.pagerduty.com/+
   3. https://events.pagerduty.com/generic/2010-04-15/create_event.json
   4. mailto:mkrebs@xxxxxxxxxxxxxxxxxx
   5. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   6. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   7. http://events.pager/
   8. http://duty.com/generic/2010-04-15/'+
   9. http://events.pagerduty.com/generic/2010-04-15/create_event.json
  10. http://www.scottklement.com/mailman/listinfo/ftpapi
  11. https://events.pagerduty.com/generic/2010-04-15/create_event.json
  12. mailto:mkrebs@xxxxxxxxxxxxxxxxxx
  13. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
  14. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
  15. http://events.pager/
  16. http://duty.com/generic/2010-04-15/'+
  17. http://events.pagerduty.com/generic/2010-04-15/create_event.json
  18. http://www.scottklement.com/mailman/listinfo/ftpapi
  19. http://www.scottklement.com/mailman/listinfo/ftpapi
  20. http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------