Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Facebook Image Post Request

Former Member
0 Likes
687

Hi guys, i´m implementing a Facebook Photo Request from ABAP, using fiddler I create this message that was succesfully posted in facebook page, now I´m trying to copy this post using if_http_client and if_http_entity multipart methods.


POST https://graph.facebook.com/767710622/photos?access_token=CAAUnJCRRhVUBAPFMl8p53wH8qfSuZAUZBo1IZCWJIo... HTTP/1.1

Content-Type: multipart/form-data; boundary=-------------------------acebdf13572468

User-Agent: Fiddler

Host: graph.facebook.com

Content-Length: 758192

---------------------------acebdf13572468

Content-Disposition: form-data; name="fieldNameHere"; filename="2012-Fiat-500-Abarth-Rear-Angle-Speed-Tilt-1920x1440.jpg"

Content-Type: image/jpeg

���� FExif��II*� ��� ��  � ���r ��   � ���� ��   � �������   � ��� ���   � �������   � �������   � ��� ���   � ��� ���   � �������   � �������(  � ��� ���1  � �������2  � ���  ��i� � ���  ��@ �� � � �Canon�Canon EOS 5D Mark II���-� '����-� '��Adobe Photoshop CS5 Windows�2011:11:18 03:02:40�� ��� � ���� ���� � ���� ��"� � ��� ���'� � ��������� � ���0230 � � ���� �� � � ���� �� �

� ���� �� � � ���� �� �

� ���� �� � � ���� �� � � ���� �� � � ��� ��� � � ��� ���

� � ���� ���� � ���81���� � ���81�� � � ��� ��� � � ���� �� � � ���� �� � � ���� �� � � ���� �� � � ��� ��� � � ������� � � ��� ��� � � ������� � � �������1� �

���� ��2� � ���  ��4� � ���

I already set the header fields Content-Type / Content-length but I´m having some issues trying to replicate the boundary in the body in line 08. Here is my code in ABAP that represents the line 08 to 10 + the content of the photo to upload.


lr_part = lr_client->request->if_http_entity~add_multipart( ).

     CONCATENATE 'form-data; name="fieldNameHere"; filename="' iv_file_name '";' INTO lv_file_header.

     CALL METHOD lr_part->set_header_field

       EXPORTING

         name  = 'content-disposition'

         value = lv_file_header.

     CALL METHOD lr_part->set_content_type

       EXPORTING

         content_type = 'image/jpeg'.

     lv_len = XSTRLEN( iv_file_xstring ).

     CALL METHOD lr_part->append_data

       EXPORTING

         data   = iv_file_xstring

         length = lv_len.

The facebook response is : "(#324) Requires upload file"

Any help will be appreciated

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
644

The exact body request i want to do with ABAP is this.

2 REPLIES 2
Read only

Former Member
0 Likes
645

The exact body request i want to do with ABAP is this.

Read only

0 Likes
644

I resolve by myself, the boundary is set by standard I didn´t have to set in the header values, the other thing is that the content-length at header level is set by SAP, i delete that header field in my code.