Malformed multipart body youtube video upload - iphone

I am trying to upload video to youtube from iPhone app. But i am getting "Malformed multipart body".
Here is my request format :-
Headers :
Authorization: Bearer ya29.AHES6ZRfVWRgOe78g4eHz8v85yFztU-ea3jEy6d_4mbEkAMVD33_1w
GData-Version: 2
Host: uploads.gdata.youtube.com
X-GData-Key: key=AI39si5TXQBExBk3eT3cn4eCOSKr1GEOJd5_HJ-RjUGPErby1Qn4aOL-HlecdrxZ3Ur7QocO8Di9wHxUdV2fSYTM3mtFCyzl_A
Slug: summer_vacation.mp4
Content-Type: multipart/related; boundary="f93dcbA3"
Request Body:
--f93dcbA3
Content-Type: application/atom+xml; charset=UTF-8
<?xml version="1.0"?>
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:media="http://search.yahoo.com/mrss/"
xmlns:yt="http://gdata.youtube.com/schemas/2007">
<media:group>
<yt:incomplete/>
<media:category
scheme="http://gdata.youtube.com/schemas/2007/categories.cat">Travel
</media:category>
</media:group>
</entry>
--f93dcbA3
Content-Type: video/mp4
Content-Transfer-Encoding: binary
--f93dcbA3--
Please help me.

I think it is because of the extra line after your second boundary (just before the Content-Type: video/mp4 header). Also, be sure to add a line between the Content-Transfer-Encoding: binary header and your binary data.
Take the Google Example as model :
POST /feeds/api/users/default/uploads HTTP/1.1
Host: uploads.gdata.youtube.com
Authorization: Bearer ACCESS_TOKEN
GData-Version: 2
X-GData-Key: key=adf15ee97731bca89da876c...a8dc
Slug: video-test.mp4
Content-Type: multipart/related; boundary="f93dcbA3"
Content-Length: 1941255
Connection: close
--f93dcbA3
Content-Type: application/atom+xml; charset=UTF-8
<?xml version="1.0"?>
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:media="http://search.yahoo.com/mrss/"
xmlns:yt="http://gdata.youtube.com/schemas/2007">
<media:group>
<media:title type="plain">Bad Wedding Toast</media:title>
<media:description type="plain">
I gave a bad toast at my friend's wedding.
</media:description>
<media:category
scheme="http://gdata.youtube.com/schemas/2007/categories.cat">People
</media:category>
<media:keywords>toast, wedding</media:keywords>
</media:group>
</entry>
--f93dcbA3
Content-Type: video/mp4
Content-Transfer-Encoding: binary
<Binary File Data>
--f93dcbA3--

Related

SOAP Request Error (The requested operation was rejected)

I sent a request via postman and it works fine and received a response, but in other environment I received an error message as below.
Url as e.g. https://URL/secure?Username=ABCD&Password=ABCD
Header:
Content-Type: text/xml
Accept: application/json, text/xml, application/xml, */*, application/soap+xml
User-Agent: APP
Accept-Encoding: gzip, deflate, br
SOAPAction: URL
Username: ABCD
Password: ABCD
ClientID: 123
OrgUnitGuid: abc-1234
OrgUnitID: 123
Body as example:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:post="url" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:core="http://Core.Model" xmlns:ser="http://schemas.microsoft.com/2003/10/Serialization/">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>ABCD</wsse:Username>
<wsse:Password>ABCD</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<----->
<-------->
</------->
</--------->
</soapenv:Body>
</soapenv:Envelope>
Response Body:
Connection=close
Pragma=no-cache
Content-Length=359
Cache-Control=no-cache
Content-Type=text/xml; charset=utf-8
<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>The requested operation was rejected. Please consult with your administrator.Your support ID is: 17985204652528471489</faultstring><detail/></soap:Fault></soap:Body></soap:Envelope>
in "Accept-Encoding: gzip, deflate, br" I remove the br and it works but with another error as below :
Connection=close
Content-Length=311
Content-Type=text/html; charset=us-ascii
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request</h2>
<hr><p>HTTP Error 400. The request is badly formed.</p>
</BODY></HTML>
I edited the Header as follow and it works fine.
some headers are extra and there is no need for most of them
Accept-Encoding:gzip, deflate
SOAPAction: URL
Content-Type: text/xml

RestSharp latest version breaks my API's post method (add Guid before and after the body)

Since latest version of RestSharp, all my post API's are failing because something has been added to the bodies I send.
Looks like a Guid id is generated and is added before and after the body for each call; the issue is it's not accepted by all my API's providers.
FYI, I created 2 identical console apps, one with version "106.12.0", and one with latest version "107.3.0". please see below the result:
Thanks in advance to help me with this
BR
-Vince
Examples:
Working with Version="106.12.0" :
before:
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name="application/xml"
<SMSBoxXMLRequest>
<username>cnoxxxx</username>
<!-- password hidden -->
<command>WEBSEND</command>
<parameters>
<service>VALAIS</service>
<text>Test de Message Sms 1</text>
<test></test>
<receiver>+4177222333444</receiver>
</parameters>
</SMSBoxXMLRequest>
after:
Not Working with Version="107.3.0" :
**--497993c6-3ef7-47fb-b527-403c1eefedf8**
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name="application/xml"
<SMSBoxXMLRequest>
<username>cnoxxxx</username>
<!-- password hidden -->
<command>WEBSEND</command>
<parameters>
<service>VALAIS</service>
<text>Test de Message Sms 1</text>
<test></test>
<receiver>+4177222333444</receiver>
</parameters>
</SMSBoxXMLRequest>
**--497993c6-3ef7-47fb-b527-403c1eefedf8--**
**--3277a8db-bd83-4f3c-af2e-d34efe76fe98**
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name="application/xml"
<SMSBoxXMLRequest>
<username>cnoxxxx</username>
<!-- password hidden -->
<command>WEBSEND</command>
<parameters>
<service>VALAIS</service>
<text>Test de Message Sms 2</text>
<test></test>
<receiver>+4177222333444</receiver>
</parameters>
</SMSBoxXMLRequest>
**--3277a8db-bd83-4f3c-af2e-d34efe76fe98--**
**--5b81fa95-a0b9-4f5c-9242-742734b0241e**
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name="application/xml"
<SMSBoxXMLRequest>
<username>cnoxxxx</username>
<!-- password hidden -->
<command>WEBSEND</command>
<parameters>
<service>VALAIS</service>
<text>Test de Message Sms 3</text>
<test></test>
<receiver>+4177222333444</receiver>
</parameters>
</SMSBoxXMLRequest>
**--5b81fa95-a0b9-4f5c-9242-742734b0241e-**-

Fiddler doesn't capture SOAP Action

How do we find the SOAP action in fiddler:-
I captured the text view of the request. It doesn't show the request SOAP action:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><a:Security soap:mustUnderstand="1" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:a="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><a:UsernameToken wsu:Id="UsernameToken-1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><a:Username>LP_DEALIO#SERVICES</a:Username><a:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Abc.1234</a:Password></a:UsernameToken></a:Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Get__CompIntfc__LP_PC_PROJECT_GEN xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/M676402.V1"><BUSINESS_UNIT>US001</BUSINESS_UNIT><PROJECT_ID>LM202017</PROJECT_ID></Get__CompIntfc__LP_PC_PROJECT_GEN></s:Body></s:Envelope>
The SOAP Action is found in the Headers Section in Fiddler. Something like this:-
POST /PSIGW/PeopleSoftServiceListeningConnector/PSFT_EP/CI_LP_PC_PROJECT_GEN.1.wsdl HTTP/1.1
Content-Type: text/xml; charset=utf-8
VsDebuggerCausalityData: uIDPo+YluAuf3g9BhNp2nGC57WUAAAAA60+5s/MerUGZDfyhBXBAgPyLh3Vk3hZMrWvRTb0KntcACQAA
SOAPAction: "CI_LP_PC_PROJECT_GEN_UP.V1"
Host: psf92extigw.am.jll.com
Content-Length: 1039
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

Server does not accept my multipart/form-data

I try to upload an image to my webservice from my iphone application. The webservice is programmed in php. I have to send the image along with a device_id as multipart/form-data.
Something is wrong with my request because the server does not accept my device_id (invalid format). I am 100% positive that the device_id is correct because it works with my other requests.
I think there is something wrong with my request structure because Charles proxy cannot decode the multipart form-data.
Here is my request (sniffed with charles proxy):
POST /api/profile/update HTTP/1.1
Host: THE_URL
User-Agent: SeduceMe/1.0 CFNetwork/548.0.3 Darwin/11.2.0
Content-Length: 6639
Accept: */*
Content-Type: multipart/form-data; boundary=---------------------------255141413922088
Accept-Language: de-de
Accept-Encoding: gzip, deflate
Cookie: PHPSESSID=tlcpnqugcpgs0skh3l2ip9ujh7
Connection: keep-alive
Proxy-Connection: keep-alive
---------------------------255141413922088
Content-Disposition: form-data; name="device_id"
mgs2AHyvfIcSXHSKE+0eHA==
---------------------------255141413922088
Content-Disposition: form-data; name="form[file]"; filename="avatar.jpg"
Content-Type: image/jpeg
RAW_JPEG_DATA
---------------------------255141413922088--
there is a great wrapper to post form/data. it is ASIHTTPRequest
please look at ASIFormData
thanks/

CardDAV with osX/iPhone clients

I am implementing a CardDAV backend to a crm package.
During the handshake with my backend the following request/response is handled:
PROPFIND /directory/ HTTP/1.1
Host: 10.0.0.202:9292
User-Agent: Address%20Book/883 CFNetwork/454.11.12 Darwin/10.7.0 (i386) (MacBookPro4%2C1)
Content-Type: text/xml; charset=utf-8
Depth: 0
Accept: */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Content-Length: 147
Connection: keep-alive
<?xml version="1.0" encoding="utf-8"?>
<D:propfind xmlns:D="DAV:" xmlns:C="DAV:">
<D:prop>
<C:current-user-privilege-set/>
</D:prop>
</D:propfind>
HTTP/1.1 207
Content-Type: text/xml; charset="utf-8"
Content-Length: 432
Connection: keep-alive
Server: thin 1.2.11 codename Bat-Shit Crazy
<?xml version="1.0" encoding="UTF-8"?>
<D:multistatus xmlns:D="DAV:">
<D:response>
<D:href>http://10.0.0.202:9292/directory/</D:href>
<D:propstat>
<D:prop>
<D:current-user-privilege-set>
<D:privilege>
<D:read/>
</D:privilege>
</D:current-user-privilege-set>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
PROPFIND /contacts/ HTTP/1.1
Host: 10.0.0.202:9292
User-Agent: Address%20Book/883 CFNetwork/454.11.12 Darwin/10.7.0 (i386) (MacBookPro4%2C1)
Content-Type: text/xml; charset=utf-8
Depth: 0
Accept: */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Content-Length: 167
Connection: keep-alive
<?xml version="1.0" encoding="utf-8"?>
<D:propfind xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:carddav">
<D:prop>
<C:addressbook-home-set/>
</D:prop>
</D:propfind>
HTTP/1.1 207
Content-Type: text/xml; charset="utf-8"
Content-Length: 408
Connection: keep-alive
Server: thin 1.2.11 codename Bat-Shit Crazy
<?xml version="1.0" encoding="UTF-8"?>
<D:multistatus xmlns:D="DAV:">
<D:response>
<D:href>http://10.0.0.202:9292/contacts/</D:href>
<D:propstat>
<D:prop>
<D:addressbook-home-set>
<D:href>http://10.0.0.202:9292/contacts/</D:href>
</D:addressbook-home-set>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
This is despite my CardDAV backend never hinting that /directory/ is anything that the client need concern itself with.
The client is returning the error The CardDAV server returned an error (207) for the user "richo", however when I patched the server to return a different status code (200) I got the same error, but with a new status code.
I am working on the hunch that something else is upsetting it about the response. I have tried returning absolute instead of relative URL's (and vice versa) to no avail.
Any input appreciated. There is a similar issue on the mac forums here that seems to end with resolution but the links are broken.
As it turned out, it was a namespace issue.
using the urn:ietf:params:xml:ns:carddav namespace where appropriate cleared it up.