Facility Control

 View Only
Expand all | Collapse all

Changing content type in ogscript.asyncPost

  • 1.  Changing content type in ogscript.asyncPost

    Posted 01-12-2017 13:07
    Hi,

    I have an application where I need to change the Content-type header that ogscript.asyncPost sends to 'text/xml'. Currently it send a Content-type of [I]application/x-www-form-urlencoded [/I]- might there be a way to change this?

    Many thanks,
    Martin


  • 2.  RE: Changing content type in ogscript.asyncPost

    Posted 01-12-2017 22:21
    DashBoard currently will use www-form-urlencoded by default unless the data segment starts with
    There are no other content types supported at this time.

    What content type were you looking for?

    #DashBoard


  • 3.  RE: Changing content type in ogscript.asyncPost

    Posted 01-15-2017 22:16
    Thanks James, this sounds like it will work for me. I will modify my data segment to see if it does the job.
    #DashBoard


  • 4.  RE: Changing content type in ogscript.asyncPost

    Posted 01-18-2017 16:09
    If it doesn't get you what you need, stay tuned - this is something we will be making more configurable in a future DashBoard release.
    #DashBoard


  • 5.  RE: Changing content type in ogscript.asyncPost

    Posted 01-29-2017 23:15
    Hi James, I've tried making my data segment start with I've pasted the code that is attached to a button, below, can you see where I'm going wrong?

    For testing the 'url' parameter contains 'http://127.0.0.1:80', my testing server runs locally and listens on port 80

    var data = 'hey there';
    ogscript.asyncPost(params.getValue('url', 0), data, processResponse, true); //do a post
    #DashBoard


  • 6.  RE: Changing content type in ogscript.asyncPost

    Posted 01-30-2017 17:33
    Ah, I have answered my own question!

    Beta version 8.2 does send a text/xml content-type. I was previously testing using release version 8.1.2 which doesn't.

    As ever, thanks for the help!
    #DashBoard


  • 7.  RE: Changing content type in ogscript.asyncPost

    Posted 01-31-2017 14:53
    Glad you were able to get it working.

    A quick update for you from the DashBoard side:
    The Dashboard 8.2 Beta was updated yesterday to include a new function to provide you with more control over your HTTP method and content type: ogscript.asyncHTTP.

    ogscript.asyncHTTP(String urlStr, String method, String reqContentType, Object data, Function callback)

    url = url
    method = GET/POST/PUT/DELETE
    contentType = application/x-www-form-urlencoded, multipart/form-data, text/plain, text/xml, application/json, whatever
    data = String, byte array, JSON object, XML




    #DashBoard


  • 8.  RE: Changing content type in ogscript.asyncPost

    Posted 02-01-2017 12:36
    This update is great, I will use this in my application.
    Tested, and works exactly as described.
    Again, many thanks!
    #DashBoard


  • 9.  RE: Changing content type in ogscript.asyncPost

    Posted 02-01-2017 16:55
    Glad to help :)
    #DashBoard


  • 10.  RE: Changing content type in ogscript.asyncPost

    Posted 02-06-2017 18:43
    I think there is one last optional parameter to ogscript.asyncHTTP, if set to true then reply to the request is passed to the callback function. It defaults to false. All working well now for me!
    #DashBoard


  • 11.  RE: Changing content type in ogscript.asyncPost

    Posted 02-06-2017 20:35
    Yes, you are correct. I did not include it in my original description since it is optional.

    If set to true, it will return a JSON object containing the response code, raw byte data (if a binary return type is found).

    ogscript.asyncHTTP(String urlStr, String method, String reqContentType, Object data, Function callback, boolean includeResponse)

    url = url
    method = GET/POST/PUT/DELETE
    contentType = application/x-www-form-urlencoded, multipart/form-data, text/plain, text/xml, application/json, whatever
    data = String, byte array, JSON object, XML
    includeResponse = true?
    Valuse passed to call back is JSON object with: {"responseCode":HTTP_RESPONSE_CODE_RETURNED, "contentType":RETURNED_CONTENT_TYPE, "url":URL_REQUESTED, "value":RETURNED_DATA_AS_STRING, "bytes":RETURNED_DATA_AS_BYTE_ARRAY}

    #DashBoard