How can I sent raw data with API connector?

Hello @Teodor, @George

I created dynamic form (all field names and values are coming from different API) . I need to use PUT method in API …

API CONNECTOR

text data coming from my dynamic form. so I cant use input data fields … I have to use JSON
my form enctype : default

Example Request :

PUT datatables/extra_client_details/1

Content-Type: application/json
Request Body:
{
“Business Description”: “Livestock sales updated”,
}`

Q1 : content type must be “application/json” . How can I modify header ? I can add new header but I cant modify

Q2 : How can I post correct data to my API end point if I cant modify header ?

I tested with postman and fiddler … It works ! but why I cant do with wappler

I need your guide @patrick @George @Teodor
I have to solve this issue (this is my second day…)

Did you test with Data Type JSON? It would send the data as a JSON string and the Content-Type is set to application/json.

yes I tested with Data Type JSON …
result like that ;

{
“timestamp”: 1552396390485,
“status”: 500,
“error”: “Internal Server Error”,
“exception”: “java.lang.NullPointerException”,
“message”: null
}

@patrick content-type doesnt change

Is this bug ?

Do you use PHP, ASP or ASP.NET?

I am using asp.net

You don’t have any data set, it sends null if it has no data. Also the Request Headers that you show are the call to the Server Connect Action, not the call from your Server Connect Action to the API.

I have created simple test form …
yeap I server connect doesnt accept data if I am using
method =PUT
data type = JSON …

but when I use ;
method = PUT
data type = TEXT
text field = {{$_POST}}
data is correct but I cant sent correct content-type

I can share simple code example/ url (as a personal message )

With JSON you have the Input Data that you can set. It only supports objects (key/value).

yeap I have to use INPUT DATA if I want to use JSON AND PUT method.
But my form , name and values are caming from different API . I think I need to use PUT and TEXT
so can you add header change option … (wappler add new header but doesnt modify )…

otherwise my project will be trash

I’m waiting good news from you …
@patrick , @George

I tested with JSON, and it seems to submit correctly. Tested with following options:

{
  "name": "test",
  "module": "api",
  "action": "send",
  "output": true,
  "options": {
    "method": "PUT",
    "url": "https://requestinspector.com/inspect/01d3ns7gda532gzqxpd1bjvt30",
    "passErrors": false,
    "dataType": "json",
    "data": {
      "foo": "bar",
      "title": "test"
    }
  }
}

How the request was received by the endpoint:

image

are you using static name in INPUT DATA ?
if you are using INPUT DATA form works … no problem …
But I am creating form dynamicly so my form field names and values are not static … so how can I use INPUT DATA …

I indeed tested with some static values

image

this is my form …

<form id="dynamic_form_updates" is="dmx-serverconnect-form" action="dmxConnect/api/Client_Datatables/Dynamic_Data_Tables_Uptade/update.aspx" method="post" name="hh" enctype="application/x-www-form-urlencoded">
            <div class="form-group p-0" dmx-repeat:repeat1="dynamic_datatable_headers_update.data.api1.data.columnHeaders.where(&quot;columnDisplayType&quot;, &quot;INTEGER&quot;, &quot;==&quot;)">
              <label class="bmd-label-floating p-0" dmx-show="((columnDisplayType != 'CODELOOKUP') &amp;&amp; (columnName != 'id') &amp;&amp; (columnName != 'client_id'))">{{columnName.replace("_", " ").titlecase()}}</label>
              <input dmx-show="((columnDisplayType != 'CODELOOKUP') &amp;&amp; (columnName != 'id') &amp;&amp; (columnName != 'client_id'))" dmx-bind:type="'number'" class="form-control mt-0" dmx-bind:id="'input'+$index" dmx-bind:name="columnName" dmx-bind:required="((isColumnNullable == false) &amp;&amp; (columnName != 'id') &amp;&amp; (columnName != 'client_id'))" dmx-bind:data-msg-required="((isColumnNullable == false) &amp;&amp; (columnName != 'client_id') &amp;&amp; (columnName != 'client_id')) ? 'This field required and INTEGER' : ''">
            </div>
            <div class="form-group p-0" dmx-repeat:repeat2="dynamic_datatable_headers_update.data.api1.data.columnHeaders.where(&quot;columnDisplayType&quot;, &quot;DECIMAL&quot;, &quot;==&quot;)">
              <label class="bmd-label-floating p-0" dmx-show="columnDisplayType != 'CODELOOKUP'">{{columnName.replace("_", " ").titlecase()}}</label>
              <input dmx-show="columnDisplayType != 'CODELOOKUP'" dmx-bind:type="'number'" class="form-control" dmx-bind:id="'decimal1'+$index" dmx-bind:name="columnName" dmx-bind:required="isColumnNullable == false" dmx-bind:data-msg-required="isColumnNullable == false ? 'This field required and DECIMAL' : ''">
            </div>
            <div class="form-group p-0" dmx-repeat:repeat10="dynamic_datatable_headers_update.data.api1.data.columnHeaders.where(&quot;columnDisplayType&quot;, &quot;STRING&quot;, &quot;==&quot;)">
              <label class="bmd-label-floating p-0">{{columnName.replace("_", " ").titlecase()}}</label>
              <input dmx-show="columnDisplayType != 'CODELOOKUP'" dmx-bind:type="text" class="form-control" dmx-bind:id="'input1'+$index" dmx-bind:name="columnName" dmx-bind:required="isColumnNullable == false" dmx-bind:data-msg-required="isColumnNullable == false ? 'This field required' : ''">
            </div>
            <div class="form-group p-0" dmx-repeat:repeat11="dynamic_datatable_headers_update.data.api1.data.columnHeaders.where(`columnDisplayType`, &quot;CODELOOKUP&quot;, &quot;==&quot;)">           
              <select dmx-show="columnDisplayType == 'CODELOOKUP'" dmx-bind:id="'selectMDPa'+$index" class="form-control" dmx-bind:options="columnValues" data-style="select-with-transition" optionvalue="id" optiontext="value" dmx-bind:name="columnName" dmx-bind:required="isColumnNullable == false" dmx-bind:data-msg-required="isColumnNullable == false ? 'This field required' : ''"> 
                <option value="">Choose {{columnName.replace("_", " ").titlecase()}}</option>
              </select> 
            </div> 
            <div class="form-group p-0" dmx-bind:id="'selecst'+$index" dmx-show="columnDisplayType == 'BOOLEAN'" dmx-repeat:repeat12="dynamic_datatable_headers_update.data.api1.data.columnHeaders.where(`columnDisplayType`, &quot;BOOLEAN&quot;, &quot;==&quot;)">
              <select dmx-bind:id="'selectMDPa'+$index" dmx-bind:name="columnName" data-style="select-with-transition" class="form-control" dmx-bind:data-msg-required="isColumnNullable == false ? 'This field required' : ''" dmx-bind:required="isColumnNullable == false">
                <option value="">Choose {{columnName.replace("_", " ").titlecase()}}</option>
                <option value="True">True</option>
                <option value="False">False</option>
              </select> 
            </div>
            <div class="form-group p-0" dmx-repeat:repeat13="dynamic_datatable_headers_update.data.api1.data.columnHeaders.where(`columnDisplayType`, &quot;DATE&quot;, &quot;==&quot;)">
              <label>{{columnName.replace("_", " ").titlecase()}}</label>
              <input type="text" class="form-control" value="" dmx-bind:name="columnName" dmx-bind:id="'dateMDPa'+$index" autocomplete="off" dmx-bind:required="isColumnNullable == false" dmx-bind:data-msg-required="isColumnNullable == false ? 'This field required' : ''">   
            </div>
            <div class="form-group p-0" dmx-repeat:repeat14="dynamic_datatable_headers_update.data.api1.data.columnHeaders.where(`columnDisplayType`, &quot;DATETIME&quot;, &quot;==&quot;)">
              <label>{{columnName.replace("_", " ").titlecase()}}</label>
              <input dmx-bind:id="'dateMDPz'+$index" type="text" class="form-control datepicker" onclick="setDatePicker();" value="" dmx-bind:name="columnName" autocomplete="off" dmx-bind:required="isColumnNullable == false" dmx-bind:data-msg-required="isColumnNullable == false ? 'This field required' : ''">   
            </div>
            <input type="hidden" value="en" name="locale" dmx-bind:value="en">
            <input type="hidden" name="dateFormat" id="dateformat1" dmx-bind:value="'MMMM dd yyyy'">
            <div class="form-group col">
              <button class="btn btn-primary" type="submit">
                <i class="fa fa-check"></i> SUBMIT 
              </button>
            </div>
          </form>

my field names are like this dmx-bind:name="columnName"
I cant use it in INPUT DATA field

well just double click on the value and use the Data Binding picker for server side expressions:

image

example Request Body:

{
“Business Description”: “Livestock sales updated”,
}`

but your request will be different …


dmx-bind:name="columnName

names are dynamic but you are using static ? (aa)

{
“developerMessage”: “The request caused a data integrity issue to be fired by the database.”,
“httpStatusCode”: “403”,
“defaultUserMessage”: “Column: aa Not Found”,
“userMessageGlobalisationCode”: “error.msg.column.not.found”,
“errors”: [
{
“developerMessage”: “Column: aa Not Found”,
“defaultUserMessage”: “Column: aa Not Found”,
“userMessageGlobalisationCode”: “error.msg.column.not.found”,
“parameterName”: null,
“value”: null,
“args”:
}
]
}

Dynamic name is not possible in the UI, you could edit the action file directly. Open the json in the editor image and change the data there in the code.

So options for the API call will become something like:

"options": {
  "url": "https://api.endpoint",
  "method": "PUT",
  "dataType": "json",
  "data": "{{$_POST}}"
}
1 Like