Your code comments are leading you into wrong assumptions, so let me rephrase the comments of your code, the code already stores the response json into a file. What you want is alredy done, but you don't seem to understand it:
Code:
lcUrl = "[URL unfurl="true"]http://192.168.1.100:5000/EsdApi/deononline/signinvoice"[/URL] && local pc IP - true, that refers to just the initial part of the URL, you send a request to a local IP address 192.168.1.100
* This addresses something like local hardaware, not a server in the internet, but tht seems to be its interface, all right.
loXmlHttp = Createobject("Msxml2.ServerXMLHTTP.6.0") && create a http request object
llNull = loXmlHttp.Open( "POST" , lcUrl, .F. ) &&..open connection - start a POST request to the URL given above in synchronous mode, which meand when you finally use send() that will wait for the response
loXmlHttp.setRequestHeader("Content-Type","application/json") && you are sending in JSON - which you state in a header that's sent to the URL at 192.168.1.100 on port 5000.
loXmlHttp.setRequestHeader("Accept", "application/json") && you are accepting JSON - which you state in this header, strictly it should be with a big A
* it could be unimportant to set this if the response will be JSON anyway, as it always is json, better know the documentation of that device you're addressing
loXmlHttp.Send(lcRequest) &&..send request - as noted above, this is done synchrnously, so the next line will execute after the response is received.
lcResponse = loXmlHttp.responseText &&..get response - Which is possible because of the synchronous usage, otherwise you'd need to wait for loXmlHttp.readyState to become 4.
*Changing that to asynchronous usage is oif no concern here, but notice it could be done and then an application can do anything else while something else waits for the response, for example a timer.
&&&&& now await response from TIMS & pick the details - this is wrong, the response is already in lcResponse
Strtofile(Alltrim(m.lcResponse), [c:\copy-cat\api\responses\]+lcOutFIle, .T.) && this writes the response into a file, that's what you asked for, the code already does that.
* This requires the varibable lcOutFIle to be set to a filename and c:\copy-cat\api\responses\ must be an existing directory. Your code does not show how lcOutFIle is set
* or whether it is a parameter, there likely is an error in not setting lcOutFIle or calling the code wrong without the filename.
jsonString = loXmlHttp.responseText && this is obsolete code, you already have that in lcResponse and it doesn't change, once the request response is received.
Now it just depends on what has to come next. If the creation of a file within the c:\copy-cat\api\responses\ directory should cause some other component, perhaps another connected hardware to react to it, then there's nothing more to do, but I'm quite sure you now want to get out the single values from the JSON string.
It would be pretty simple, if you programmed all this in Javascript then oJS = JSONSTRING would simply make oJS an object that this JSONSTRING actually is, when "run" (or evaluated) in JS. And you could get at the properties oJS.traderSystemInvoiceNumber, for example.
Well, as you're obviously using VFP, you're now on a journey to learn something new, either you use that API with a Javascript program to not have the translatkion/parsing hurdle, or you make use of libraries like nfJSON to turn the JSON into a VFP object or cursor.
In the first place, by definition of the acronym JSON a JSON string is Javastrict OBJECT notation, so it is an Object, not a table or record. Libraries like nfJSON are not necessary in Javascript itself, as JSON there is native, it already is what you now need to convert because you use VFP and not Javascript. You're not alone, libraries like this also exist for other languages, like PHP. But you're likely having a totally oversimplified assumption and imagingation of JSON automatically becoming a DBF when you store it to a file. But don't thinkj every JSON is simply turned into the same thing, JSON can encode anything, It's usage of a specific API call like this one in the end requesting a "signinvoice", that gets the JSON representing that.
Just one last comment: Your thread title points out that you want to read a response txt file into a string (1), in your post you ask how to generate a txt file (2), the total opposite. Your code already does 2 and it still has the response string in lcResponse and in jsonString, becasue it does the step to read out the loXmlHttp.responseText property twice into two variables with different names. I don't know what's not working, but if your code is failing it's surely failing on a level you don't yet have understood yourself. If you don't find a file in c:\copy-cat\api\responses\ with current datetime, then the error likely is about not setting lcOutFIle. If this is all code in progress and first time usage, well, then the pointer to the nfJSON library should help you get on with this.
Chriss