I Have to post data to Odata webservice. In this post I need to pass token header also. I got token value now I have to try to pass Token Header value and Data also but when i do this I'm getting this kind of ERROR: Stream was not readable

  try
                byte[] auth = Encoding.UTF8.GetBytes("mobtest" + ":" + "welcome1");
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://Server:8000/sap/opu/odata/sap/ZCUST_TESTING_SRV/post_cust");
                //byte[] byteArray = Encoding.UTF8.GetBytes(postXml);
                byte[] byteArray = Encoding.ASCII.GetBytes(jsonnew);
                request.Credentials = new NetworkCredential("mobtest","welcome1");
                request.ContentType = "application/atom+xml";
                request.Method = "GET";
                //request.Headers["Authorization"] = "Basic " + System.Convert.ToBase64String(auth);
                request.Headers["X-CSRF-Token"] = "Fetch";
                HttpWebResponse responseH = (HttpWebResponse)request.GetResponse();
                xToken = responseH.Headers["X-CSRF-Token"];
                Console.WriteLine("xToken : " + xToken.ToString());
                responseH.Close();
                try
                    HttpWebRequest request_post = (HttpWebRequest)WebRequest.Create("http://Server:8000/sap/opu/odata/sap/ZCUST_TESTING_SRV/post_cust");
                    request_post.Credentials = new NetworkCredential("mobtest", "welcome1");
                    request_post.Method = "POST";
                    request_post.Headers["X-CSRF-Token"] = xToken;
                    Console.WriteLine("xToken POST : " + xToken.ToString());
                    request_post.ContentType = "application/json";
                    request_post.Accept = "application/json";
                    request_post.ContentLength = byteArray.Length;
                    Stream dataStream1 = request_post.GetRequestStream();
                    dataStream1.Write(byteArray, 0, byteArray.Length);
                    Console.WriteLine("byteArray : "+byteArray);
                    dataStream1.Close();
                    Console.WriteLine("datastream1");
                    HttpWebResponse response1 = (HttpWebResponse)request.GetResponse();
                    Console.WriteLine("Post response : " + response1.ToString());
                    dataStream1 = response1.GetResponseStream();
                    StreamReader reader1 = new StreamReader(dataStream1);
                    Console.WriteLine("  Console.WriteLine(reader1 : " + reader1);
                    string responseFromServer1 = reader1.ReadToEnd();
                    Console.WriteLine("  Console.WriteLine(responseFromServer1 : " + responseFromServer1);
                    Console.Read();
                    reader1.Close();
                    dataStream1.Close();
                    response1.Close();
                catch(Exception exp)
                    MessageBox.Show("Post Error : "+exp.Message);
            catch(Exception ex)
                MessageBox.Show("Error : "+ex.Message);

Hi Ashwin,
                  That is C# windows application below i mention the XML data and Code also.
string postXml = @"<?xml version='1.0' encoding='UTF-8'?>"+
"<entry xml:base='http://serverip:8000/sap/opu/odata/sap/ZCUST_TESTING_SRV/'\n"+"xmlns='http://www.w3.org/2005/Atom'"+
"xmlns:m='http://schemas.microsoft.com/ado/2007/08/dataservices/metadata'"+
"xmlns:d='http://schemas.microsoft.com/ado/2007/08/dataservices'>"+
"<content type='application/xml'>"+
"<m:properties>"+
"<d:Kunnr>800DUR298</d:Kunnr>" +
"<d:Land1>avi</d:Land1>" +
"<d:Name1>dur</d:Name1>" +
"<d:Name2>ven</d:Name2>" +
"<d:Ort01>chennai</d:Ort01>" +
"<d:Pstlz>500060</d:Pstlz>" +
"<d:EStatus>X</d:EStatus>"+
"</m:properties>"+
" </content>"+
" </entry>";
  try
                byte[] auth = Encoding.UTF8.GetBytes("mobtest" + ":" + "welcome1");
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://Server:8000/sap/opu/odata/sap/ZCUST_TESTING_SRV/post_cust");
                byte[] byteArray = Encoding.UTF8.GetBytes(postXml);
                request.Credentials = new NetworkCredential("mobtest","welcome1");
                request.ContentType = "application/xml";
                request.Method = "GET";
                request.Headers["X-CSRF-Token"] = "Fetch";
                HttpWebResponse responseH = (HttpWebResponse)request.GetResponse();
                xToken = responseH.Headers["X-CSRF-Token"];
                Console.WriteLine("xToken : " + xToken.ToString());
                responseH.Close();
                try
                    HttpWebRequest request_post = (HttpWebRequest)WebRequest.Create("http://Server:8000/sap/opu/odata/sap/ZCUST_TESTING_SRV/post_cust");
                    request_post.Credentials = new NetworkCredential("mobtest", "welcome1");
                    request_post.Method = "POST";
                    request_post.Headers["X-CSRF-Token"] = xToken;
                    Console.WriteLine("xToken POST : " + xToken.ToString());
                    request_post.ContentType = "application/xml";
                    request_post.Accept = "application/xml";
                    request_post.ContentLength = byteArray.Length;
                    Stream dataStream1 = request_post.GetRequestStream();
                    dataStream1.Write(byteArray, 0, byteArray.Length);
                    Console.WriteLine("byteArray : "+byteArray);
                    dataStream1.Close();
                    Console.WriteLine("datastream1");
                    HttpWebResponse response1 = (HttpWebResponse)request.GetResponse();
                    Console.WriteLine("Post response : " + response1.ToString());
                    dataStream1 = response1.GetResponseStream();
                    StreamReader reader1 = new StreamReader(dataStream1);
                    Console.WriteLine("  Console.WriteLine(reader1 : " + reader1);
                    string responseFromServer1 = reader1.ReadToEnd();
                    Console.WriteLine("  Console.WriteLine(responseFromServer1 : " + responseFromServer1);
                    Console.Read();
                    reader1.Close();
                    dataStream1.Close();
                    response1.Close();
                catch(Exception exp)
                    MessageBox.Show("Post Error : "+exp.Message);
            catch(Exception ex)
                MessageBox.Show("Error : "+ex.Message);
Message was edited by: jitendra kansal
Message was edited by: jitendra kansal

Similar Messages

  • I have downloaded Adobe Photoshop digitally but when i activated adobe I keep getting this error message Adobe Premiere Elements.exe - NO DISK. There is no disk in the drive. Please insert a disk into drive/device/harddisk/dr1

    I have downloaded Adobe Photoshop digitally but when I activated adobe I keep getting this error message Adobe Premiere.exe - NO DISK - There is no disk in the drive. Please insert a disk into drive/device/harddisk/DR1

    It sounds like you downloaded the wrong application, namely Adobe Premiere Elements.
    If you meant Adobe Photoshop Elements, you're in the wrong forum.  This is not the Elements forum.
    Here's the link to the forum you want:
    https://forums.adobe.com/community/photoshop_elements/content
    If you mean Photoshop proper, since you are posting in the Photoshop forum, give version details and your system specs.
    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    a screen shot of your settings or of the image could be very helpful too.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • When insert my lexar USB flash drive I get the message that the disk was not readable by this computer.  It has worked previous to this and I do not want to lose the data by reformatting the drive.  How can I reformat this drive and not lose my data?

    When insert my lexar USB flash drive I get the message that the disk was not readable by this computer.  It has worked previous to this and I do not want to lose the data by reformatting the drive.  How can I reformat this drive and not lose my data?

    You can't reformat it and not wipe everything on it.
    Have you tried a different USB port?
    Only other option, back it up on a different computer.

  • Keep getting a "the disk you inserted was not readable by this computer" when I insert my printer cord into either USB port.  Recently installed a portable hard drive for back up purposes.  Related?

    Keep getting a "the disk you inserted was not readable by this computer" when I insert my printer cord into either USB port.  Recently installed a portable hard drive for back up purposes.  Related?

    Does your printer have a slot for an SD card?  Is there are card in the slot?  If so, the computer is trying to mount that card as an external device.  It might be corrupted so that it can't be read.

  • I purchased an audio book from I tunes but when I sync with my I phone it respond with error saying could not read or write the file. It only sync parts 2

    I purchased an audio book from I tunes but when I sync with my I phone it respond with error saying could not read or write the file. It only sync parts 2

    Those videos are probably not in an iPod-friendly format. It’s picky about that. You can try converting them, if possible.
    As for the audiobooks, are you sure they haven’t synced? You’ve enabled it to sync books and checked the “Audiobooks” section of your iPod?

  • Why do i get the "the disk you inserted was not readable by this computer" error when I don't even have a disk inserted?

    Why do I keep getting "the disk you inserted was not readable by this computer" caution message when I don't have a disk inserted???

    Unfortunately, I saw this error for the first time this morning. It's on my wife's iMac running Lion, and it appeared when the machine locked up on a Software Update screen prompting her to run an update (I'm assuming this was the recent Security Update).
    After numerous failed attempts to force-quit or otherwise safely restart, she hit the power button, and when the machine came back up it failed to recognize the startup disk. I've since successfully restarted from several different (external) startup disks without incident, but each time I attempt to fix the internal drive via Disk Utility the disk shows only as "Media" and all the usual options to Repair or Verify the Disk are greyed out, leaving only the Erase Disk option.
    Are we totally hosed?

  • When I insert my Dvd-R it says The disk you inserted was not readable by this computer.Why is this happening ???

    When I insert my Dvd-R cd it saids "The disk you inserted was not readable by this computer." Please help
    thanks

    This is a blank disc?  A disc you burned?   Burned discs have a relatively high failure rate if you buy cheap DVDs.  I bought some Dynex ones once and about one in every four fails.
    Have you tried other DVDs to check if it is a drive issue?

  • I have recently upgraded our Choir's website, using iWeb, (it was previously done using other software. I get the home page on the screen, but when I click on links, I get this error message; "Parse error: syntax error, unexpected T_STRING in /var/www/vir

    I have recently upgraded our Choir's website, and used iWeb to create the upgrade. It was previously done with other software.
    Now, when I go to the site, (comc.ca), the first page comes up fine, but when I click on the links to other pages, I get this message.....
    Parse error: syntax error, unexpected T_STRING in /var/www/virtual/comc.ca/htdocs/Site_3/Contact_Us.html on line 1
    I went to an Apple store, (I still have time left on my one-to-one period), but didn't get an answer.
    Any suggestions really appreciated.
    Thanks,
    Larry

    Sorry, but it doesn't help JTANNA.
    What is your definition of "more efficiently"? If it's limitation of search results, branded search, and limitation of styling your results then google search is more efficient. Real developers rely on their own developments. For example: how can google search display results from a password-protected site? They can't.
    best,
    Shocker

  • I can't sign in to my icloud control panel, I have uninstalled and reinstalled icloud, but when i sign in I just get a permanent "egg timer" I can't make any changes to my set up! Can anyone help?

    Hi can anyone help with my problem?
    thanks Caz

    You have to go to icloud.com from your computer browser, not from your iPad.  When you do, you won't bet the prompt to install iCloud.

  • I download Firefox 4 which is supposed to be compatible with OSX10.4 and above. But when I click the icon I get a message that it is not compatible with version of OSX10.4.11 and it wont load

    I download Firefox 4.o and drag to app folder then to dock. When I double click on the dock icon I get a message the forefox is not compatible with this version of OSX (which is OSX10.4.11). What gives?

    Firefox 4 requires at least OS X 10.5 and an Intel Mac. You can get the latest version of Firefox 3.6 from http://www.mozilla.com/en-US/firefox/all-older.html
    Mozilla are working to prevent Mac users with non-compatible systems from getting the notification about Firefox 4, and also not displaying the "Download Firefox 4" button on http://www.mozilla.com

  • I installed or updated to iCloud Control Panel 2.0 or later for Windows and signed in, but when I go to iCloud Photos I see a message that it's not enabled. I go to the iCloud Control Panel won't allow a ck mark to be put, pls help!

    I went to the ICloud Control Panel 2.1 to enable iCloud photos, the area to put a ck mark is grayed out and won't let me enable it.
    This is on my HP desktop Windows 7. I have iphone 5 and newset iPad that do fine on iCloud.
    Please help me to get my iCloud photos enabled on my desktop.

    Hello,
    You might not have the plugin for Firefox installed. Adobe has two different versions of Flash - one for Internet Explorer and another for Firefox. Internet Explorer uses ActiveX. You can check if Firefox has the plugin by going to:
    * Tools > Add-ons > Plugins, or
    * [Image: New Fx Menu] > Add-ons > Plugins
    In Firefox, go to this link and Adobe should give you right correct installer:
    * https://get.adobe.com/flashplayer/
    If for whatever reason it is not choosing the correct OS for you, you can manually select Windows Vista and "Other Browsers" here:
    * https://get.adobe.com/flashplayer/otherversions/

  • I purchased an iBook, moved it to my Ipad, starting reading - but when I went to continue reading a few hours later the book was not on my iPad anymore - help please

    .

    You should be able to re-download it for free (assuming that it's still available and you use the same iTunes account that you originally used) : http://support.apple.com/kb/HT2519

  • I cannot pull up pictures from iphoto. I see them but when I click on them, I get an exclamation mark inside a triangle

    I cannot open pictures from iphoto.  I see them but when I click on them, I get this exclamation point inside a triangle

    The ! turns up when iPhoto loses the connection between the thumbnail in the iPhoto Window and the file it represents.
    What version of iPhoto? Assuming 09 or later...
    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Rebuild iPhoto Library Database from automatic backup.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. .
    Regards
    TD

  • I keep trying to download my photos to my MacBook Pro, when I insert my disc I get this response: You inserted a blank CD. Choose an action from the pop-up menu or click Ignore. Anyone know how to fix this?

    I have been trying to download photo's from a CD onto my MacBook pro but when I insert the disc I get this box that pops up onto my screen:  You inserted a blank CD. Choose an action from the pop-up menu or click Ignore. Is there a way to fix this so I can use my photo's?

    Bummer. Could be a problem with the MBP drive. Are you using Re-writable discs maybe?
    Check the discs work in your HP machine. They may have burnt but not successfully. Your HP machine may not be able to open them either.
    Have you considered using a USB flash device to transfer the photos, or just copy them over your home network? CD is a slow an cumbersome method.

  • External HDD: "The disk you inserted was not readable by this computer"

    Hi,
    I have an external drive with important data on it (there is a backup, but there is also some non-backuped data as well...). I cannot access the external drive because I receive a "The disk you inserted was not readable by this computer" message connecting it. I was wondering, if you have some advice on how to get my data back?
    I have a WD Elements 2 TB (about 2 months old), I am using is with an iMac, latest Snow Leopard. The drive used to work all fine. Now, I receive a "The disk you inserted was not readable by this computer" every time I connect it. Same thing happens if connected to my MacBook Pro.
    What happened?: I was copying files to the external drive. I the middle of it, I received a message complaining I that assumedly ejected the drive by pulling the USB cable out instead of properly ejecting it software-side (I did not do this). The drive symbol was gone. Now, I plug the drive out an reconnected it. The drive symbol showed up again. I continued copying files on the drive, but after some 30 seconds, I received the same error message again. One more time, I disconnected and reconnected the drive - this time to another USB port. The drive showed up, but I was not able to copy files on it (I am using muCommander, it just kept showing 0kb progress). I restarted the Mac. Since then I am getting the "The disk you inserted was not readable by this computer." The drive symbol does not show up anymore.
    I was googling the problem: in one forum there was a suggestion to click "initialize drive" and than to "repair" in DiscUtility. I clicked initialize drive and the drive is shown in DiscUtility, but "repair" and "verify" are greyed out. I read more posts on it, one posts suggested NOT to click initialize because that means format in Mac OS language (btw: ***, why is it not called format).
    That is the situation at the moment. What is the best - if there is - way to get my data back? DiscWarrior?
    I very much appreciate your advice!
    Daniel

    "Initializing" a drive has been normal computer terminology for decades.  "Formatting" generally referred to the high-level preparation also called "erasing."  None of this is "Mac OS language."
    Disk Warrior will not likely fix the problem you have.  DW can repair a damaged directory, but your error suggests an even worse problem of directory corruption.  I suggest you try using DW if you have it.  Visit the Alsoft site to determine the limitations and usage of the version you have.  It may not be able to boot your computer depending upon what version of DW you have and how new your computer is.
    If you have no success with DW then see the following:
    Basics of File Recovery
    Files in Trash
    If you simply put files in the Trash you can restore them by opening the Trash (left-click on the Trash icon) and drag the files from the Trash to your Desktop or other desired location.  OS X also provides a short-cut to undo the last item moved to the Trash -press COMMAND-Z.
    If you empty the Trash the files are gone. If a program does an immediate delete rather than moving files to the Trash, then the files are gone.  Recovery is possible but you must not allow any additional writes to the hard drive - shut it down. When files are deleted only the directory entries, not the files themselves, is modified. The space occupied by the files has been returned to the system as available for storage, but the files are still on the drive. Writing to the drive will then eventually overwrite the space once occupied by the deleted files in which case the files are lost permanently. Also if you save a file over an existing file of the same name, then the old file is overwritten and cannot be recovered.
    General File Recovery
    If you stop using the drive it's possible to recover deleted files that have not been overwritten by using recovery software such as Data Rescue II, File Salvage or TechTool Pro.  Each of the preceding come on bootable CDs to enable usage without risk of writing more data to the hard drive.  Two free alternatives are Disk Drill and TestDisk.  Look for them and demos at MacUpdate or CNET Downloads.
    The longer the hard drive remains in use and data are written to it, the greater the risk your deleted files will be overwritten.
    Also visit The XLab FAQs and read the FAQ on Data Recovery.

Maybe you are looking for