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

[Ftpapi] (no subject)



Hi Scott,

I'm having problem with the message text (especially german characters u with double dot above) returned by the Rest service which is UTF-8. CCSID of my screen is 1141 (Euro german) and job CCSID is 273 (german). I went through some of the questions and answers posted at this forum and has been told to use the http_setCCSIDs which converts request from job ccsid and response back to the job ccsid as well, but it seems to no avail. Could someone enlighten me what should I do here :-


     D*
     D Response        S          65535A   Varying Inz
      *______________________________________________________________________
      * Call the URI of Order Processing in order to get the
      * result of the call
      *______________________________________________________________________
     P SHARED_callExternalPostRestService...
     P                 B                   Export
     D                 Pi                  LikeDs(SHARED_ResponseObject)
     D RequestUri                 65535A   Options(*Varsize) Varying
     D Debug_FileName             65535A   Options(*Varsize) Varying
     D RequestString              65535A   Options(*Varsize) Varying
     D*
     D responseObject  DS                  LikeDs(SHARED_ResponseObject)
     D Pointer         S               *
     D rc              S             10I 0
     D*
      /Free
         Clear Response;

         http_setCCSIDs(1208: 0);
         http_debug(*ON: Debug_FileName);

         pointer = http_persist_open(RequestUri);

         if (pointer = *null);
             responseObject.Response = http_error;
             responseObject.StatusCode = -1;
             return responseObject;
         endif;

         rc = http_persist_req( 'POST' : pointer: RequestUri
                                :0 : *null:
                                %addr(RequestString:*data):
                                %len(RequestString):
                                 0: %paddr(saveResponse):60:'':
                                'application/json');

         http_persist_close(Pointer);

         if (rc = 1);
            responseObject.Response = *Blanks;
            responseObject.StatusCode = rc;
            return responseObject;
         EndIf;

         responseObject.Response = Response;
         responseObject.StatusCode = rc;
         return responseObject;

      /End-Free
     P                 E
      *______________________________________________________________________
      *  saveResponse - This subprocedure reads the result returned by the
      *  service
      *______________________________________________________________________
     P saveResponse    B
     D                 Pi            10i 0
     D fd                            10i 0 value
     D data                       65535A   options(*varsize)
     D length                        10i 0 value
     C*
      /Free
             If (length > 0);
               HTTP_xlate(length : data : TO_EBCDIC);
               response += %subst(data : 1 : length);
             ENDIF;
             return length;
      /End-Free
     P                 E
      *_________________________________________________________________________
      *  Evaluate the Json Response message
      *_________________________________________________________________________
     P SHARED_getJsonValue...
     P                 B                   Export
     D                 PI         65535A   Varying
     D  Json_Message              65535A   Varying value
     D  Key                          32A   Varying Const
     D
     D*
     D  docNode        S                   Like(yajl_val)
     D  node           S                   Like(yajl_val)
     D  errMsg         S            500    Varying
     D  MessageReturn...
     D                 S          65535    Varying
     C*
      /Free
          docNode = yajl_buf_load_tree( %addr(Json_Message:*data):
                                        %len(Json_Message):
                                         errMsg);
          if (errMsg <> '');
              return errMsg;
          Endif;

          node = yajl_object_find(docNode:Key);
          MessageReturn = yajl_get_string(node);
          yajl_tree_free(docNode);

          Return MessageReturn;
      /End-Free
     C*
     P                 E
                                                             
-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi