Jump to content

Trouble posting to Drupal via REST/cURL & BaseElements Plugin /

This topic is 1609 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi everyone,

I'm trying to post data to a Drupal application from FileMaker via the BaseElements plugin. I'm getting a token, setting authentication, headers, and the post variables via the BaseElements functions and I've followed examples but I'm getting the following error:  {"error":"The type link relation must be specified.”}    I can't find any information about what this error might be. Does anyone have any idea based on the output I've gathered below?

A working cURL command that I'm basically trying to replicate  that can be run from the command line is here:

curl --include \
  --request POST \
  --user res_user:"password" \
  --header 'Content-type: application/hal+json' \
  --header "X-CSRF-Token: $X_CSRF_TOKEN" \
  --data-binary '{"_links":{"type":{"href":"http://server.mskcc.org/rest/type/node/event"}},
  "title":[{"value":”Novel Approaches to Mating Drosophila"}],
  "body":[{"value":"Tea ?: Yes<br>Tea Time: Tea at 1:15 PM"}],
  "field_shared_location_text":[{"value":"ZRC Auditorium"}],
  "field_shared_sponsor":[{"value":"Developmental Biology"}],
  "field_event_hosts_text":[{"value":"Alexander Rudensky"}],
  "field_shared_people_text":[{"value":"Name of Speaker: Steven Reiner<br>Speaker\u0027s Credentials: M.D.<br>Speaker\u0027s Title: Professor, Department of Microbiology and Immunology<br>Speaker\u0027s Affiliation: Columbia University Medical Center<br>Institution Location: New York, NY"}],
  "type":[{"target_id":"event"}]}' \

I've attached the script I'm working with as an image.Screen Shot 2016-08-03 at 6.53.16 PM.png

thanks in advance. :)




BE_Curl_Trace returned:

== Info:   Trying
== Info: Connected to dev.mskcc.org ( port 80 (#0)
== Info: Server auth using Basic with user 'res_user'
=> Send header, 0x12c bytes (0x12c)
0000: POST /entity/node?_format=hal_json HTTP/1.1
0x2d: Host: server.mskcc.org
0x42: Authorization: Basic cmVzX2RydXBhbDpUcnU3SCZrQQ==
0x75: User-Agent: libcurl-agent-base-elements-plugin/3.2
0xa9: Accept: */*
0xb6: Content-Type: application/hal+json
0xda: X-CSRF-Token: q3LKwzWvNtlP2_X79TpJATfEnOB8HV-_lDaVCiTK8gg
0x115: Content-Length: 353
=> Send data, 0x161 bytes (0x161)
0000: " {\"_links\":{\"type\":{\"href\":\"http://dev.mskcc.org/rest/ty
0x40: pe/node/event\"}},..  \"field_event_type\":[{\"value\":\"Seminar
0x80: \"}],..  \"title\":[{\"value\":\"Sister Cells that Feast and Fas
0xc0: t --- Why Growth and Repair May Not be Fair XI\"}],..  \"field_s
0x100: hared_datetime\":[{\"value\":\"2016-06-13T17:15:00\"}],..  \"typ
0x140: e\":[{\"target_id\":\"event\"}]}"
== Info: upload completely sent off: 353 out of 353 bytes
<= Recv header, 0x1a bytes (0x1a)
0000: HTTP/1.1 400 Bad Request
<= Recv header, 0xf bytes (0xf)
0000: Server: nginx
<= Recv header, 0x24 bytes (0x24)
0000: Content-Type: application/hal+json
<= Recv header, 0x1c bytes (0x1c)
0000: Transfer-Encoding: chunked
<= Recv header, 0x18 bytes (0x18)
0000: Connection: keep-alive
<= Recv header, 0x18 bytes (0x18)
0000: Keep-Alive: timeout=10
<= Recv header, 0x33 bytes (0x33)
0000: Cache-Control: must-revalidate, no-cache, private
<= Recv header, 0x1a bytes (0x1a)
0000: X-UA-Compatible: IE=edge
<= Recv header, 0x16 bytes (0x16)
0000: Content-language: en
<= Recv header, 0x21 bytes (0x21)
0000: X-Content-Type-Options: nosniff
<= Recv header, 0x1d bytes (0x1d)
0000: X-Frame-Options: SAMEORIGIN
<= Recv header, 0x28 bytes (0x28)
0000: Expires: Sun, 19 Nov 1978 05:00:00 GMT
<= Recv header, 0x25 bytes (0x25)
0000: Date: Wed, 03 Aug 2016 11:02:45 GMT
<= Recv header, 0x2 bytes (0x2)
<= Recv data, 0x40 bytes (0x40)
0000: 35
00x4: {"error":"The type link relation must be specified.”}      <——— here's the error
0x3b: 0
== Info: Closing connection 0


BE_Response_Headers returned:

HTTP/1.1 400 Bad Request
Server: nginx
Content-Type: application/hal+json
Transfer-Encoding: chunked
Connection: keep-alive
Keep-Alive: timeout=10
Cache-Control: must-revalidate, no-cache, private
X-UA-Compatible: IE=edge
Content-language: en
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Date: Wed, 03 Aug 2016 11:02:45 GMT

Link to comment
Share on other sites

  • 4 weeks later...

With the help of Ronnie Rios, the folks at BaseElements and especially, Christian from MonkeyBreadSoftware.de and his Monkey Bread plugin,  we got this working, with the following script:




# start a new transfer

Set Variable [ $curl ; Value: MBS("CURL.New" ) ] 


# set URL

Set Variable [ $r ; Value: MBS("CURL.SetOptionURL"; $curl; "http://server34343.mskcc.org/rest/session/token") ] 


# set post

Set Variable [ $result ; Value: MBS("CURL.SetOptionPost"; $curl; 1) ] 

Set Variable [ $result ; Value: MBS("CURL.SetOptionUsername"; $curl; "res_user") ] 

Set Variable [ $result ; Value: MBS("CURL.SetOptionPassword"; $curl; password") ] 

Set Variable [ $result ; Value: MBS("CURL.SetOptionHTTPHeader"; $curl; "Content-type: application/hal+json"; "X-CSRF-Token: $"&$r) ] 

Set Variable [ $result ; Value: MBS("CURL.SetOptionURL"; $curl; "http://dev.mskcc.org/entity/node?_format=hal_json") ] 

Set Variable [ $result ; Value: MBS("CURL.SetOptionPostFields"; $curl; "{\"_links\":{\"type\":{\"href\":\"http://dev.mskcc.org/rest/type/node/event\"}}, \"field_event_type\":[{\"value\":\"Seminar\"}],\"title\":[{\"value\":\"MBS TEST 4 after talking to Christian\"}], \"field_shared_datetime\":[{\"value\":\"2016-06-13T17:15:00\"}], \"type\":[{\"target_id\":\"event\"}]}"; "UTF-8")


# run transfer

Set Variable [ $ErrorCode ; Value: MBS("CURL.Perform";$curl) ] 


# get result as text and debug messages:

Set Variable [ $TextResult ; Value: MBS("CURL.GetResultAsText";$curl) ] 

Set Variable [ $DebugMessages ; Value: MBS("CURL.GetDebugAsText";$curl) ] 


# cleanup

Set Variable [ $r ; Value: MBS("CURL.Cleanup"; $curl) ] 

Set Variable [ $result ; Value: MBS("CURL.Cleanup"; $curl) ] 




Link to comment
Share on other sites

  • 5 months later...
  • Newbies

Hi Steven,

i'm trying to show data in Drupal 8 from Filemaker db and i don't know how to proceed. Can you share your approach. What did you used the BaseElement Plugin and/or the Monkey Bread Plugin?

Thank you in advance 


Link to comment
Share on other sites

@kiva - in the last post ( with the working script ), he is using the Monkeybread Plugin. Looking at both, it seems like you can do the same thing with the BE plugin. We, most often, use the BE plugin the send files or make API connections. We have done it with both...but BE has always done what we need.

Link to comment
Share on other sites

  • 2 weeks later...

@kiva   I forget what the problem was but we tried (hard) to  get it working with the BaseElements plugin and there was something it couldn't do, at the time. And we ended up getting it working with MonkeyBread.

I'm attaching the working script again.. it may include a few lines that we added in for good measure.  The "MBS" function name is missing because we haven't yet purchased it and were using a demo at the time.  We're waiting for the next version of FMServer to purchase the plugin.

I found the following which looks useful if you want to give BaseElements a try first:



Link to comment
Share on other sites

  • Newbies

Thanks for the answers. The MBS Plugin was helpful to me and have done the connection from Filemaker to Drupal. I can push data and hand over Filemaker-fields to the CMS. I have used your posted script with few changes. Thanks again

Link to comment
Share on other sites

On 3/7/2017 at 7:27 PM, Steven Cappiello said:

...The "MBS" function name is missing because we haven't yet purchased it and were using a demo at the time.  We're waiting for the next version of FMServer to purchase the plugin.

What is the logic behind waiting?

Link to comment
Share on other sites

This topic is 1609 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By naio
      The content of myField is:
      text before quotes "quoted text" and I want to format a JSON object:
      JSONFormatElements ( "{\"object\":\"" & myTable::myField & "\"}") the quotes within my data make invalid JSON, so I escape quotes:
      JSONFormatElements ( "{\"object\":\"" & Substitute ( myTable::myField; "\""; "\\\"")  & "\"}")
      Then I get valid JSON like this:
      {"object" : "text before quotes \"\u0016quoted text\u0016\""} I wonder where these \u0016 characters added around the quoted text come from, I don't want them there
      How should I escape quotes without this problem?
    • By Selva
      I have tried to pass the below JSON data to the API. But it doesn't accept the JSON data due to Square brackets[] in the JSON Key. Is there any solution available to pass the below value?
      JSONSetElement ( "{}" ; "[Name | Last]" ; "Test" ; JSONString )
      We need the output like below.
      "[Name | Last]": "Test"
      Thanks in advance.
    • By Will_Logic
      Hi, I have been using Base Elements command BE_FileMakerSQL in FileMaker script to SQL select data, and return with '<c>' as field(column) delimiter, and '<r>' as the row delimiter. The below line worked before, I dumped a whole FM database with these delimiters showing in text files. But somehow, now if I run below line, it seems to have changed to ?only allow? 1 character for the delimiter, which of course doesn't make sense anyway with varied characters in the data:
      BE_FileMakerSQL ( $sql_select;  "<c>" ; "<r>" ; $fm_file ) The string this returns now looks like for example: 352265<gwgwh<474848<<wegwgw<65755<gwgw ....
      i.e. it has only taken the first character of the delimiter, I changed delimiter string to test with eg "A≠" instead of "<c>", same problem, it then only inserts "A" as delimiter. Just wonder if anyone can guess what might have happened here?
      Thanks kindly any suggestions!
    • By 360Works
      New Major Version Release:
      Scribe 4!
      We are excited to announce a new major version of a popular 360Works plug-in, introducing Scribe 4! 360Works Scribe is the ultimate document automation plug-in for FileMaker; it allows integration with Word, Excel, and PDF documents. In this release, we are taking it to the next level by adding in the ability to read your scanned documents, such as receipts, forms, or contract PDF files, with OCR (Optical Character Recognition) functionality. Additionally, we added features to allow you to merge PDFs and get meta-data from them, plus multiple fixes for existing functionality in Scribe.
      New OCR Functionality
      Scribe 4 ships with brand new OCR functionality to read your scanned documents and extract text to be added into FileMaker. For example, a law firm can scan in loads of paper legal contracts and have the text extracted and imported into the appropriate FileMaker records! Scribe leverages the technology of Amazon Textract which goes beyond simple OCR by not only extracting text but also identifying key information like the contents of fields in forms.

      Click here for a cool demo file showing how to use this new OCR functionality in Scribe!
      New PDF Merge Feature
      We added two new functions to merge and manipulate PDFs with Scribe. For example, if you have a couple of PDFs stored in container fields, the new function ScribePDFMerge allows the two PDFs to be merged together. The new ScribePDFSplice function allows a multi-page PDF to be split up into smaller PDFs. This is beneficial if you have containers with multi-page PDFs, and only need to utilize a specific part of the entire PDF file.
      Get PDF Meta-Data
      You can now get meta-data about a PDF, such as the name of the author and page count. The new ScribeGetPDFAttributes function will return various meta-data about a PDF. This can be helpful if you want to have FileMaker manage PDF files according to the author or number of pages specified in the meta-data.
      Multiple Improvements to Existing Functionality
      We also made several upgrades to the existing Scribe functionality. When using Excel with Scribe, the Excel cell reading and writing images to Excel cells has been greatly improved. We also made fixes for the ScribeDocSubstitute function for replacing a value.
      Try or Buy Scribe 4
      Scribe 4 is available now at the Scribe product page. Active maintenance subscribers for Scribe or the 360Works Portfolio Bundle can download new major version 4 at no additional cost. All purchases within the last 12 months are still under an active maintenance subscription. If the maintenance on Scribe has not been renewed within the last 12 months, you will need to purchase a new license to use Scribe 4.

      For new license purchases, we have several license types available based on number of users, client-side or server-side usage, and a solution bundle license for developers with a vertical market solution.

      A free, fully functional demo is available to test Scribe. While in demo mode, Scribe will run for 2 hours every time you launch FileMaker (or FileMaker Server, for server deployment).

      Full pricing, license type information, and the demo version can be accessed at the Scribe product page.
        Try or Buy Scribe 4     Stay updated with 360Works


      Questions? Please Email [email protected]
    • By Will_Logic
      Hi, I am using the Base Elements plugin Execute SQL command to select SQL on a table in another FileMaker file. For a file with many fields and quite a lot data in some fields, this times as about 1 minute just for SQL SELECT command for 1,000 rows. I haven't used MBS (monkeybread software) plugin yet, but I wonder if anyone knows if it is significantly faster?
      I.e. BE_FileMakerSQL vs. MBS(FM.SQL.Execute..) - is one significantly faster?
      Here's the code to select 1,000 rows for reference, $timer_seconds comes as about 60 seconds here. If I export same table internally in FileMaker using the menu export to Excel, it takes 29 minutes for all 41,000 rows, so timing seems similar for the Base Elements SQL. (NB there is some flag going on here in the FileMaker database so internal export gets 41,000 rows but script SQL SELECT COUNT(*) gets 200,000 rows for same table, but I don't think that is relevant to my question).
      Set Variable [$time1; Value: Get(CurrentTimeUTCMilliseconds)] Set Variable [$part_ca; Value: BE_FileMakerSQL ( "SELECT * FROM Contact_ACTIVITY OFFSET 100000 ROWS FETCH FIRST 1000 ROWS ONLY" ; "&≠≠&" ; "EOR≠≠EOR" ; "DataContacts11" )] Set Variable [$timer_seconds; Value: (Get(CurrentTimeUTCMilliseconds) - $time1) / 1000] MBS command I think would be something like:
      MBS( "FM.SQL.Execute"; "DataContacts11"; "SELECT * FROM Contact_ACTIVITY OFFSET 100000 ROWS FETCH FIRST 1000 ROWS ONLY" ; ...delimiters here I'm assuming.. ) We only have base FileMaker here on machine I am using, which can run the Base Elements plugin, but to run MBS plugin, needs FileMaker Pro Advanced to install it I think, am getting several databases in roughly same FM format where script workspace disabled, hence need to use SQL select run from script in my own external FileMaker file. Might consider getting FMP Pro Advanced if MBS is faster.
      Tx any suggestions!
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.