Results 1 to 5 of 5

Thread: [Answers] Web service

Hybrid View

  1. #1
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    I am returning a result set using print_json(aresult) and I want to include the "Content-type: APPLICATION/JSON"
    A:
    At the top of your .rsp page
    Code:
    Response.contenttype = "Application/json"
    <%
    response.contenttype = "..."
    %>
    it is Lianja/VFP.

    case insensitive.

    Try removing all the HTML tags. You are generating JSON and outputting HTML.

    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="application/json; charset="UTF-8" />
    </head>
    <body>
    ...
    </body>
    </html>
    Remove those.

    The response.contenttype = "application/json" should be being sent then your JSON data.



    Q:
    NetworkRequest. I have had a go at uploading an XML file to my website. I have some confusion about what "args" were required, my solution seems to involve some redundancy. This is what I thought might work (It doesn't!)
    Code:
    // Upload xml file to the web
    oRequest = createObject("networkrequest")
    oRequest.async = .f.
    oRequest.username = "myUserName"
    oRequest.password = "myPassword"
    oRequest.putFile("ftp://www.timelinecontinuum.com/9-11.xml?username='myUserName'&password='myPassword' ",xmlName)
    y = oRequest.ErrorString
    In debug, after oRequest.username, I see:
    Code:
    ? oRequest.username
    ^
    Property/Variable 'USERNAME' not found
    After the putFile request I get:

    Code:
    Logging in to www.timelinecontinuum.com failed: authentication required
    A:
    You can however only use http:// or https:// not ftp:// with "NetworkRequest"
    If you want to upload using sftp i would recommend that you look at using the chilkat components for Lianja from http://www.chilkatsoft.com/lianja.asp



    Q:
    I would like to have the targetFile and source file both coming from variables.
    It works Ok with source file as xmlName where xmlName contains something like "C:\Lianja\Data\timeline\9-11.XML".
    But targetFile resists my attempts to use a variable. I would like to pass through a file name and a subdirectory on my Host.
    So TargetFile would be something like "/DataXML/filename.xml".
    A:
    You can substitute variables into strings using &varname. which would let you use variables. Otherwise you can just create the character variable and use that as an argument to the method call.
    Try omitting the / from the start of the target file. Does that directory already exist and if so does it have the correct permissions.
    it may be that the target can only be a filename.
    One solution would be to have a username that when logged in uses a different directory on the ftp server but that would require some configuration and is Server dependent.



    Q:
    I want to upload an xml file called "MH370.aspx" to a directory on my web site "www.timelinecontinuum.com".
    After your reply I have tried various combinations of the formats shown in the thread "http://www.lianja.com/community/showthread.php?1121-File-upload-and-download-in-Lianja" without success.
    The two attempts below give me the error "Method not allowed":
    Code:
    oRequest.putFile("http://www.timelinecontinuum.com/MH370.aspx","9999.xml")
    oRequest.putFile("http://www.timelinecontinuum.com/MH370.aspx?password='zermattb'&username='TM7o33XU' ","9999.xml")
    You can see I have some misunderstanding of what the params should be; and probably other misunderstandings that I am not aware of.
    A:
    You should be able to do this, replacing username, password, host/targetfile, sourcefile with the relevant details:
    Code:
    oRequest = createObject("networkrequest")
    oRequest.postFile("ftp://username:password@host/targetfile","sourcefile")
    The "Method not allowed" messages will be coming from the server, saying it doesn't accept HTTP uploads.
    As mentioned before, if it's an sftp server, have a look at the Chilkat components.



    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352
    Last edited by josipradnik; 2016-03-16 at 03:54.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us