Thank you so much for your help guys, I've managed to make some progress. I'm going to mark this thread resolved and will start a new one if I face any other problems.
Hi Skydiver
Thank you for your reply and the great suggestions, the "magic strings" will be populated from fields in a database that will be setup in the main application, I just hard coded them in for testing purposes and the same with the error trapping and exceptions, i'll make those more...
Looks like i'm finally making some progress, managed to deserialze the stream data, next step is to try and read the XML.
public class ModitarApiConnection
{
public class Document
{
}
public Object ModitarWebRequestCall()
{...
Thanks guys, I'm back and hopefully with a clearer head. Just to clarify based on the last two posts, it would be better for me to deserialise the stream and then pass that object back to my calling method, instead of stream to string and then too object.
Thanks Skydiver
So with my original plan, once i got the string of data back, i would then need to deserialise that so that i can read the XML. Is my thinking correct with that ?
Thanks Skydiver, i'm going to step away from this for a bit I'm getting frustrated and making stupid mistakes and missing obvious things. I actually have a ProcessXML class that calls the ModitarWebrequestCall method, I should be doing me deserialization and xml reading in that class, my initial...
Ah i see now where the OrderedItem comes from, I agree I need to spend more time on serialization etc but i'm on a bit of a time crunch with this one. I also need more experience with XML , this is one section of my development career that i have ignored completely over the years. Ive created...
Thanks Skydiver
I'm just getting bogged down with all the different options and confusing myself even more. Main focus now is just to get this XML data deserialized. In your example i'm assuming that "OrderedItem" is a node in the XML file ?
I did see something on the web where the dev streamed the data into memory with MemoryStreamer and then deserialised it afterwards, not sure if i'm over complicating this for myself or not.
Hi Sheepings, I've attached the XML file as it's quite a complex XML file, I haven't worked with anything like it before.
" Also note that Deserialize on line 13 expects a xml reader and not a stream reader. "
So do i have to re-write the stream reader code and replace it with the XMLreader...
I'm kind of fumbling around in the dark here, and I'm not sure i'm doing this correctly but i'm getting a "root element missing" error when i hover over the exception.
string content = string.Empty;
try
{
using (var response =...
Hi Sheepings
Thank you for your advice, yes that's exactly what I need to do with the XML.
i already built the StreamReader that's receiving the data, do i have to replace all that code to use the XmlSerializer ? or can i just deserialise the content that has already come through ?
Hi Sheepings
Sorry about that, the data is coming through as XML. From my limited knowledge on XML it looks quite complex with loads of child nodes. So i'm not quite sure how to process this and also haven't attempted anything like this in C# yet.
Hi All
I'm currently consuming a REST api and i need some guidance on reading the response data. My experience with reading this type of data is very minimal and i'm trying to find the best way to do it.
below is the code for getting the API data.
public string ModitarWebRequestCall()...
It's unfortunately one of those situations where the client for whatever reason cannot provide a good a spec of the work required, neither any API documentation, trial and error coding LOL.
Hi All
managed to get it working, the issue was with the encoding, the below works perfectly.
request.Headers.Add("username", username);
request.Headers.Add("password", password);
request.Headers.Add("collection", collection)...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.