After doing a file upload using Web API code to a Geoprocessing Service which takes a file as an input, an error message will surface like below. Feature service attachments are not affected by this bug.
//http://sampleserver6.arcgisonline.com/arcgis/rest/services/911CallsHotspot/GPServer/uploads/upload
{
"error": {
"code": 500,
"message": "Error in upload Item for service 911CallsHotspot",
"details": []
}
}
Here is Web API code to repro this issue.
https://gist.github.com/phpmaps/9791947
The problem resides in the file upload request sent out from the proxy. Adding these lines will allow Charles / Fiddler to capture the request and see the values being passed. The issue is tied to the request text "boundary". It seems the PHP cURL extension makes boundary automatically.
Adding these lines to proxy allows the problem to be visualized in Charles and Fiddler to debug the traffic.
curl_setopt($this->ch, CURLOPT_PROXY, "127.0.0.1");
curl_setopt($this->ch, CURLOPT_PROXYPORT, 8888);
Boundaries are written to separate POSTed values and when filename="/private/var/tmp/64X64.png"
is in the request, it fails.
------------------------------b31d8b5a3f93
Content-Disposition: form-data; name="file"; filename="/private/var/tmp/64X64.png"
Content-Type: application/octet-stream
âPNG
IHDR@@™iqfiiCCPICC ProfileH
≠WgXS…ûSí@HhÅH Ω “´Ù^§
6BH(!ÇàÿêE÷Çäÿ–◊»¢"veÏ˝bAAYu±ÅrÁP‘}ˆÓø;yŒÃõwfi˘Êõo 3Äl[$JAÂHfä√¸<YsbbYîáÅ?`(lNÜ»#44¸kz�ja∫nFÿ˙WŸˇÆP‡Ú28 °∞:ûõ¡IÖ¯(X3G$ŒÄDÿ”[î)"àAà˜8q78~wåi"¬º†¶)õ-NÄ>yV'⁄ë•
When the filename in boundary is like this filename="64X64.png"
life is good.
------------------------------b31d8b5a3f93
Content-Disposition: form-data; name="file"; filename="64X64.png"
Content-Type: application/octet-stream
âPNG
IHDR@@™iqfiiCCPICC ProfileH
≠WgXS…ûSí@HhÅH Ω “´Ù^§
6BH(!ÇàÿêE÷Çäÿ–◊»¢"veÏ˝bAAYu±ÅrÁP‘}ˆÓø;yŒÃõwfi˘Êõo 3Äl[$JAÂHfä√¸<YsbbYîáÅ?`(lNÜ»#44¸kz�ja∫nFÿ˙WŸˇÆP‡Ú28
When life is good the response looks like this.
{
"success": true,
"item": {
"itemID": "ieb07775b-523a-4461-807b-141cdbd25d0e",
"itemName": "64X64.png",
"description": null,
"date": 1395866245830,
"committed": true,
"serviceName": "911CallsHotspot.GPServer"
}
}