Server does not accept my multipart/form-data - iphone

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/

Related

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

Azure Media Services AssetDeliveryPolicies in REST Api - do they gone?

I'm writing application in which i upload video, encode it, and then i need to expose a link to encoded video. One of the steps is to create AssetDeliveryPolicies and link it to Asset, i tried to do that, but to my surprise i don't see such entity as AssetDeliveryPolicies on that endpoint:
https://wamsamsclus001rest-hs.cloudapp.net/api/AssetDeliveryPolicies
Do anybody have tried to do something like that? I'm not sure whether i'm doing something wrong or it is already deprecated and handled in some other way.
Create an AccessDeliveryPolicy
POST https://media.windows.net/api/AssetDeliveryPolicies HTTP/1.1
Content-Type: application/json
DataServiceVersion: 1.0;NetFx
MaxDataServiceVersion: 3.0;NetFx
Accept: application/json
Accept-Charset: UTF-8
Authorization: Bearer [token here]
x-ms-version: 2.11
x-ms-client-request-id: [guid here]
Host: media.windows.net
{"Name":"Clear Policy",
"AssetDeliveryProtocol":7,
"AssetDeliveryPolicyType":2,
"AssetDeliveryConfiguration":null}
Link an AssetDeliveryPolicy to an Asset.
POST https://media.windows.net/api/Assets('nb%3Acid%3AUUID%3A86933344-9539-4d0c-be7d-f842458693e0')/$links/DeliveryPolicies HTTP/1.1
DataServiceVersion: 1.0;NetFx
MaxDataServiceVersion: 3.0;NetFx
Accept: application/json
Accept-Charset: UTF-8
Content-Type: application/json
Authorization: Bearer [token here]
x-ms-version: 2.11
x-ms-client-request-id: [new guid here]
Host: media.windows.net
{"uri":"https://media.windows.net/api/AssetDeliveryPolicies('nb%3Aadpid%3AUUID%3A92b0f6ba-3c9f-49b6-a5fa-2a8703b04ecd')"}
Where nb%3Acid%3AUUID%3A86933344-9539-4d0c-be7d-f842458693e0 is the URL Encoded value of AssetId and nb%3Aadpid%3AUUID%3A92b0f6ba-3c9f-49b6-a5fa-2a8703b04ecd is the URL Encoded value of the AccessDeliveryPolicy Id.
Source

Hessian Web Calls using REST Client

How to call a Hessian Server from the REST Client Google extension
This is my sample request
Request
POST /RPCService HTTP/1.1
Content-Type: x-application/hessian
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.6.0_27
Host: asvignesh.in:9000
Accept: text/html, image/gif, image/jpeg, *; q=.2, /; q=.2
Connection: keep-alive
Content-Length: 27
c..m..getbloglist
How to Send Hessian Grammar c..m..getbloglist format as Key Value pair like Content-Type: Text/html

Fiddler soap action in proxy client

This is what fiddler has to say for a request I am trying to make to an external webservice
Request:
POST https://service100.emedny.org:9047/MHService HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Host: service100.emedny.org:9047
Content-Length: 7933
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Response: HTTP 500 Internal server error.
Miscellaneous: X-backside-transport: FAIL FAIL
TextView: Faultcode-Rejected by policy from client
Could soap Action =”” be the probable cause of this Faultcode? I am sure a client handshake was established
Now this is the trace viewer svclog
THank you

Unable to assemble multipart/form-data request

I'm trying to implement file upload functionality in the iPhone app. Server code is tested and works when files are uploaded from the desktop browser, so I moved to implementing the Objective-C client code. I'm assembling HTTP requests body manually, and despite that it looks correct, it is rejected by the server (server handler unable to extract the parts from multipart content). In desperation I've simplified the form to having only one parameter, but it still does not work.
I've captured the network traffic and I could see that Wireshark could not parse my multipart content as well (have a look at screenshots: Firefox request, iPhone request). I'm pasting it below in hope that you could see the errors I can't see.
Thanks in advance.
Firefox:
POST /cubepaint/actions/gallery/post HTTP/1.1
Host: [...]
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-GB; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Authorization: Basic [...]
Content-Type: multipart/form-data; boundary=---------------------------20072377098235644401115438165
Content-Length: 180
-----------------------------20072377098235644401115438165
Content-Disposition: form-data; name="deviceId"
12345
-----------------------------20072377098235644401115438165--
HTTP/1.1 200 OK
Date: Sat, 17 Oct 2009 22:09:21 GMT
Server: Apache/2.2.3 (Debian) DAV/2 SVN/1.4.2 mod_python/3.2.10 Python/2.4.4 mod_ssl/2.2.3 OpenSSL/0.9.8c
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
iPhone:
POST /cubepaint/actions/gallery/post HTTP/1.1
Host: [...]
User-Agent: Copenhagen/1.0 CFNetwork/459 Darwin/9.8.0
Content-Type: multipart/form-data; boundary=----------0E7B16E6-CD3D-4213-9B42-07DA30822C74
Accept: */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Authorization: Basic [...]
Content-Length: 187
Connection: keep-alive
----------0E7B16E6-CD3D-4213-9B42-07DA30822C74
Content-Disposition: form-data; name="deviceId"
00000000-0000-1000-8000-0016CBCC0B61
----------0E7B16E6-CD3D-4213-9B42-07DA30822C74--
HTTP/1.1 200 OK
Date: Sat, 17 Oct 2009 22:04:07 GMT
Server: Apache/2.2.3 (Debian) DAV/2 SVN/1.4.2 mod_python/3.2.10 Python/2.4.4 mod_ssl/2.2.3 OpenSSL/0.9.8c
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
Your iPhone version indicates keep-alive but doesn't specify a length. Not sure that's enough to cause trouble.
Also, is it possible your server is checking for user-agent strings it recognizes (say, for backward-compatibility mode)?
I'd also compare the two in a text editor that shows CR/LF characters to make sure you're getting proper line endings.
Another thing you could try is create a simple web-page that does a multipart POST and run it from the iPhone browser (instead of the Mac one) then check the headers that go across the wire. Or you could snag a toolkit like ASIHTTPRequest and see what kind of output it generates for multi-part posts (or just use the toolkit instead of trying to write your own).
Good luck
Solved by reading RFC 2046 (MIME specification): boundary between parts of multipart message should contain two leading '-'s, and last boundary should additionally contain two trailing '-'s. The boundary in the request header and request body in the Firefox request differ:
---------------------------20072377098235644401115438165
and
-----------------------------20072377098235644401115438165
The last boundary looks like this:
-----------------------------20072377098235644401115438165--
You really could not see this with the eye when there are so many leading '-'s in the original boundary.