Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

VFP 9.0 API Troubles After Server Upgrade

VFP 9.0 API Troubles After Server Upgrade

VFP 9.0 API Troubles After Server Upgrade


A vendor I work with upgraded a few of their servers we use and now a VFP program that connects to it via its APIs has started erroring.

This code use to work.

CODE -->

**** HyperCaster API Info
sHyperCaster = "" 
sADDFolder = "content_api"
sCMbyFN = "content_metadata_by_filename/"
fnMedia = "CHURCH_ADBC_20230122.mov"


*** Get metadata from HyperCaster
*** Content Metadata by Filename POST
oXMLHTTP.Open("POST", sHyperCaster + sCMbyFN + fnMedia, .f.)
oXMLHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
lcSendText = sHyperCaster + sCMbyFN + fnMedia
? lcSendText
lcResultText = oXMLHTTP.responseText

Instead now the PostResult file sending this:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  <title>Not Found</title>
  <link rel="icon" href="/favicon.ico" type="image/x-icon" />
  <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
  <style media="screen" type="text/css">
    html { font-family: "Trebuchet", "Trebuchet MS", sans-serif; padding: 85px 10px; font-size: 19px; line-height: 1.4; color: #737373; background: #f0f0f0 url("/images/500_error_background.png") }
    body { max-width: 575px; _width: 575px; padding: 30px 20px 50px; border: 1px solid #b3b3b3; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; margin: 0 auto; -moz-box-shadow: 0 1px 15px #333, inset 0 1px 0 #fff; -webkit-box-shadow: 0 1px 15px #333, inset 0 1px 0 #fff; box-shadow: 0 1px 15px #333, inset 0 1px 0 #fff; background: #fcfcfc; text-align: center; }
    h1 { margin: 10px; font-size: 34px; text-align: center; }
    p { margin: 1em 0; text-align: center;}
    img { margin: -10px auto 16px auto; }
    ul { margin: 40px auto 0 auto; padding: 0; list-style-type: none; text-align: center; }
    ul li { font-size: .9em; margin:10px 8px; display: inline; text-align: center; }
    li a { text-decoration: none; }
    a img {border: none; }
    div.dialog { max-width: 500px; _width: 500px; margin: 0 auto; }

  <div class="dialog">
    <a href="http://www.telvue.com/" target="_blank"><img id="logo" src="/images/telvuelogo.gif" height="68" width="246"  alt="TelVue Corporation" title="TelVue Corporation" /></a>
    <h1>Page Not Found</h1>
    <p>Sorry, you may have mistyped the address or the page may have moved.</p>
      <li><a href="http://telvue.com/support/" target="_blank">Technical Support</a></li>
      <li><a href="http://www.telvue.com/support/product-documentation/" target="_blank">Product Documentation</a></li>


Any thoughts or recommendations? I have reached out them and waiting to hear back, too

Much thanks,

"..if you give a man a fish he is hungry again in an hour. If you teach him to catch a fish you do him a good turn."
-- Anne Isabella Thackeray Ritchie.

RE: VFP 9.0 API Troubles After Server Upgrade


<title>Not Found</title>
I think that the url (Ip adress) is not correct (anymore), maybe the new servers got new ones.


RE: VFP 9.0 API Troubles After Server Upgrade

The new servers did not get new IPs. The IP is correct.

The title not found I believe is referring to the "CHURCH_ADBC_20230122.mov" from the fnMedia = "CHURCH_ADBC_20230122.mov" not being found. But I have confirmed that is on there. And if I take the combination of those variables:
- sHyperCaster + sCMbyFN + fnMedia =

CODE --> 

And put it in a browser, it works. See image.

But the body of the error returned does say page not found so I am not 100% sure that the <title> is referring to the title of the program.

So that is what is making me think there is something to with how VFP is sending it.


"..if you give a man a fish he is hungry again in an hour. If you teach him to catch a fish you do him a good turn."
-- Anne Isabella Thackeray Ritchie.

RE: VFP 9.0 API Troubles After Server Upgrade

This line was the problem:


oXMLHTTP.Open("POST", sHyperCaster + sCMbyFN + fnMedia, .f.) 

POST needs to be GET. For some reason, the older servers did not seem to mind.


oXMLHTTP.Open("GET", sHyperCaster + sCMbyFN + fnMedia, .f.) 

Found out that...

Quote (Brian w/ Telvue>)

Where you put

in the browser it sends the request as a GET request. POST is usually reserved for creating resources.

"..if you give a man a fish he is hungry again in an hour. If you teach him to catch a fish you do him a good turn."
-- Anne Isabella Thackeray Ritchie.

RE: VFP 9.0 API Troubles After Server Upgrade

Just to explain why a POST could have worked previously:

The difference of a POST and GET request is that a POST usually has a body sent with it. But technically also a GET request can send data in a body. And both request types arrive at the HTTP service (listening to requests on port 80 usually), no matter if POST or GET or other types of request. So also a POST request arrives at the same endpoint.

Your code does not send a body, that would e parameter of oXMLHTTP.Send(). But the line previous to that points out that the developer writing that intended to send over something:


oXMLHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded') 
You only set that header to indicate to the web server, what the body contains.

As you changed to GET, you can now also remove that line, it makes even less sense than in the context of a POST request stating the body content type and then not sending a body, as a GET usually has no body at all.

It's not, by the way, a default that the body sent in a POST request is saved as a file at the given URL so a GET request reads that, that would be a security risk as anybody then could upload any files just by using that request type. And the target of a POST request can also be a script in a script language. That should execute, not be replaced. Then also a GET request should not be able to read code instead of executing the script that is intended to produce the HTML pages. Otherwise, hackers could really simply get at code and find vulnerabilities. You see, even a wrong response to a GET could be a security issue.

A POST is also not risky in that it is a very commonly used request method for an HTML form, for example. And form input also is only saved, if code procesing it does so. The response to a POST used by the submit of an HTML form can be anything a GET request can also serve. As a response of you filling out the HTML form for a login, for example, you could get served your user profile HTML page or when you submit a valid key of a product you get a download from a form submit. This explains, why a POST request can serve the same responses as a GET request can.

It's fine to change to GET as you only intend to get something and don't need the POST mechanism for that, but it's not generally pointing out a misconfiguration of the old server or a security hole fixed with the new server. It's purely the decision of the web server admins to specify how the web server reacts to requests. If you try to get the logo of tek-tips by a POST request, for example, you get a response with error status code 405 and the body then does not contain the logo image but an HTML page pointing out the request method is not allowed. The "Allowed" response header also tells you what request methods are allowed, and GET is among them, but also others.

So what's all the fuzz about request types, if they are interchangeable and all still have the same composition of headers, target URL, and body sent with them? Semantics, purely semantics. For example that a HTML form you configure to use the GET method encodes the user input within the request URL and you then can see the parameters in the address the browser displays and that these parameters are hidden in the post body, if you pick the POST method, is neither making the POST request safer nor better. The input is still only transferred securely if the transfer protocol is HTTPS and not just HTTP. And it's just semantics and standard implementation of a browser to encode the HTML form input values this or the other way, so this is more a topic of compliance to the decided standards, no more, no less.

I guess newer webserver versions are just preconfigured to only allow GET requests to files that clearly are media files, a POST makes no sense semantically, even though it would be harmless and the web server could decide to react to both requests the same way, just serving the file.

Of course, I don't know why there even was the intent to send a request body. Maybe that code was just taken from an example of a POST request and thus "misusued". Maybe there originally was something sent with the POST request. In some sites it would not be unusual that every request has authentication with it. For example, a cryptographic signature could be sent with each request to allow the server to know the client request is genuine, even if not using HTTPS. Such authentication-related things are usually within request headers, though, not a request body.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close