Here's the scenario: We have an iOS app that makes an HTTP POST request to my .NET Web API. The method that is invoked is PostPicture
(below):
// POST api/blah
[HttpPost]
public string PostPicture(HttpRequestMessage msg)
{
HttpContext context = HttpContext.Current;
etc...
As you can see, this method takes in an HttpRequestMessage
. The issue I'm having is I constantly have to rely on the iOS app to make the call just to be able to pass in the HttpRequestMessage
to test my .NET code.
I had the iOS developer send me the HTTP POST contents that the device (iOS) is sending to my Web API. He sent it in a text document.
Question: Is there any way to take those raw contents and basically emulate an HTTP POST request with these contents (and of course create an HttpRequestObject
based on those contents) within my code?
Here's the HTTP POST contents that he sent me:
{\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf370
{\fonttbl\f0\fnil\fcharset0 Menlo-Bold;\f1\fnil\fcharset0 Menlo-Regular;}
{\colortbl;\red255\green255\blue255;\red81\green112\blue255;}
\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\deftab529
\pard\tx529\pardeftab529\pardirnatural
\f0\b\fs22 \cf0 \CocoaLigature0 2013-06-14 15:17:32.969 blah[11765:907] insertEntity URL: http://domain/blahWS/API/blah/PostPicture\
\pard\tx529\pardeftab529\pardirnatural
\f1\b0 \cf0 Printing description of mikeTest:\
\{\
"imageDataBlob" : "JVBERi0xLjMKJcTl8uXrp\\/Og0MTGCjQgMCBvYmoKPDwgL0xlbmd0aCA1IDAg\\nUiAvRmlsdGVyIC9GbG...",\
"layer" : "0",\
"blah" : "YES",\
"pdf" : "JVBERi0xLjMKJcTl8uXrp\\/Og0MTGCjQgMCBvYmoKPDwgL0xlbmd0aCA1IDAg\\nUiAvRmlsdGVyIC9GbG...",\
"imageCount" : "3",\
"groupID" : "1_userName",\
"longitude" : -95.98030149945615,\
"latitude" : 36.74866412304039,\
"JsonData" : "[\{ \\"geometry\\" : \{\\"x\\":-95.98030149945615 , \\"y\\": 36.74866412304039\} ,\\"attributes\\":\{ \\"Feature\\" : \\"Chemical_Treatment\\",\\"Type\\" : \\"\\",\\"Prod_Name\\" : \\"\\",\\"Line_Dia\\" : \\"\\",\\"Line_Mat\\" : \\"Select\\",\\"Prspct_Fld\\" : \\"\\",\\"Comments\\" : \\"\\",\\"HTML_LINK\\":\\"http:\\/\\/subdomain.url.net\\/blahWS\\/ImageViewer\\/Display\\/1_userName_2013-06-14_15:17:02\\",\\"APP_LAT\\":\\"36.74866412304039\\",\\"APP_LONG\\":\\"-95.98030149945615\\", \\"groupID\\":\\"1_userNamep_2013-06-14_15:17:02\\"\}\}]",\
"Timestamp" : "2013-01-01 12:12:23",\
"username" : "_userName"\
\}\
\pard\tx529\pardeftab529\pardirnatural
\f0\b \cf2 (lldb) }