Select to view content in your preferred language

problem with attachments via a proxy page

2770
3
03-17-2011 10:30 AM
MarkWells
Deactivated User
Hi

I have a feature service being accessed via a proxy page so that it can be secured, and accessed using a dynamically generated token. (However, this problem appears to happen regardless of whether the service is secured - it's a proxy page issue).

I am using the attachment inspector, out of the box in the Flex API. the problem is that new attachments do not hit the rest endpoint correctly. Instead of a standard response, I receive a string of HTML which represents the "Add Features" rest endpoint:

<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
  <title>Add Attachment (Feature ID: 420)</title>
  <link href='https://community.esri.com/ArcGIS/rest/ESRI.ArcGIS.Rest.css' rel='stylesheet' type='text/css'>
</head>
<body>
<table width="100%" id="userTable">
<tr>
<td id="titlecell">ArcGIS Services Directory</td>
<td align="right">
Logged in as: webapp | <a href="https://community.esri.com/ArcGIS/rest/logout">Logout</a>

 | <a href="https://46.137.26.209/ArcGIS/tokens/gettoken.html" target="_blank">Get Token</a>
</td>
</tr>
</table>
<table id="navTable" width="100%">
<tbody>
<tr valign="top">
<td id="breadcrumbs">
<a href="https://community.esri.com/ArcGIS/rest/services">Home</a> > <a href="https://community.esri.com/ArcGIS/rest/services/PointsEdit/FeatureServer">PointsEdit (FeatureServer)</a> > <a href="https://community.esri.com/ArcGIS/rest/services/PointsEdit/FeatureServer/0">sde.DBO.WWTW_Points</a> > <a href="https://community.esri.com/ArcGIS/rest/services/PointsEdit/FeatureServer/0/420">420</a> </td>

<td align="right" id="help">
<a href="http://46.51.162.119/ArcGIS/SDK/REST/servicesdirectory.html" target="_blank">Help</a> | <a href="?f=help" target="_blank">API Reference</a></td>
</tr>
</tbody>
</table>
<div class='restHeader'>
<h2>Add Attachment (Feature ID: 420)</h2>
</div>
<div class='restBody'>
<i>
Note: This operation is only supported via POST
</i>

<br/>
<br/>
<br/>
<form enctype='multipart/form-data' method='post' action='/arcgis/rest/services/PointsEdit/FeatureServer/0/420/addAttachment?token=IJusyJW5AYDMhkRGrCcqkOiv3GHwceQA0sRy_rwprgQ.'>
<table class='formTable'>
<tr valign='top'>
<td>
Attachment
</td>
<td>
<input type='file' name='attachment' />
</td>
</tr>
<tr>
<td>
Format:</td>

<td>
<select name="f">
<option value='html'selected = "true">HTML</option>
<option value='pjson'>JSON</option>
</select>
</td>
</tr>
<tr><td colspan='2' align='left'><input type='submit' value='Add Attachment' /></td></tr>
</table>
</form>
</div>
</body>
</html>


So the POST which pushes an attachment to the endpoint is causing the service to respond with its HTML page prompt - as if the attachment data is not being delivered correctly.

If I remove the proxy page and route the request directly, everything works correctly.

I have stepped through the proxy page, and confirmed that the POST data does get transferred to the request to ArcGIS Server; it does seem to be pushing the bytestream across to the new request.

I noticed though that the content type on the new request (inside the proxy) is defined as "application/x-www-form-urlencoded". However, the original content type posted from the Flex application is "multipart/form-data". I wonder if this is the problem - as it's binary data we're trying to push up as an attachment. I have briefly tried changing this to multipart/form-data in the proxy, but this causes the connection to close prematurely and the service request fails. I havent figured out why.

Is there any further guidance here? Is there a known issue where attachments cannot be added via a proxy page connection?
Tags (2)
0 Kudos
3 Replies
DasaPaddock
Esri Regular Contributor
Are you using the proxy code from http://help.arcgis.com/en/webapi/flex/help/content/proxy.htm

These do pass through the "Content-Type".
0 Kudos
MarkWells
Deactivated User
Dasa,

Thank you! This appears to have solved it. I must have been using an older version of the proxy code.

Mark
0 Kudos
AHay
by
Deactivated User
I have been struggling with this for ages

Did you use the new proxy page from flex API help,

namely
http://help.arcgis.com/en/webapi/flex/help/index.html#/Using_the_proxy_page/017p0000000v000000/

it asks for the proxy page info ( passwords etc) to be included in appsettings tag of webconfig.

Does anyone know the syntax i should use , i have tried a lot of variations and if i put anything in that tag my application throws a gen 500 error (get nothing at all) and if i remove tag i get application with no secured services ( i.e proxy page is not reachable)

any ideas
0 Kudos