ABAP SDK: /goog/cl_storage_v1 delete_objects => Error in HTTP Request: Invalid version (44)

Hello,

I try to delete an object from a bucket with the “delete_objects” method of /goog/cl_storage_v1, but I always get an exception with error message “Error in HTTP Request: Invalid version (44)”.

I can list_objects and get_objects w/o any problem,

The service account has the “Storage Admin” role, I’m using ABAP SDK Version 1.5 (can’t upgrade to 1.7. atm).

This is my code, what am I holding wrong?

Thanks for any hint,

Walter

  METHOD process_files.
    DATA pagetoken  TYPE string.
    DATA maxresults TYPE string VALUE '50'.
    DATA rawdata    TYPE xstring.

    TRY.
        DATA(api) = NEW /goog/cl_storage_v1( iv_key_name = i_key ).

        WHILE sy-index = 1 OR pagetoken IS NOT INITIAL.
          api->list_objects( EXPORTING iv_p_bucket     = i_bucket
                                       iv_q_prefix     = i_folder
                                       iv_q_maxresults = maxresults
                                       iv_q_pagetoken  = pagetoken
                             IMPORTING es_err_resp     = DATA(err_resp_list)
                                       es_output       = DATA(out) ).
          IF err_resp_list-error IS NOT INITIAL.
            MESSAGE err_resp_list-error_description TYPE 'E'.
          ENDIF.

          pagetoken = out-next_page_token.

          LOOP AT out-items ASSIGNING FIELD-SYMBOL() WHERE size > 0.

            api->add_common_qparam( iv_name  = 'alt'
                                    iv_value = 'media' ).
            api->get_objects( EXPORTING iv_p_bucket = i_bucket
                                        iv_p_object = -name
                              IMPORTING es_raw      = rawdata
                                        es_err_resp = DATA(err_resp_get) ).
            api->clear_common_qparam( 'alt' ).
            IF err_resp_get-error IS NOT INITIAL.
              WRITE / 'cant read object'.
              CONTINUE.
            ENDIF.
            " (processing of "rawdata")

            api->delete_objects( EXPORTING iv_p_bucket = i_bucket
                                           iv_p_object = -name
                                 IMPORTING es_err_resp = DATA(err_resp_del) ).
            IF err_resp_del-error IS NOT INITIAL.
              WRITE / 'cant delete object'.
              CONTINUE.
            ENDIF.

          ENDLOOP.
        ENDWHILE.
        api->close( ).

      CATCH /goog/cx_sdk INTO DATA(err).
        WRITE / err->get_text( ).
    ENDTRY.
  ENDMETHOD.

This issue can occur if there is a space in the object name.

So before passing the object name for the delete method, call the following method to escape URL:

<fs_line>-name = cl_http_utility=>escape_url( <fs_line>-name )

So it works, thank you very much!