0

How do I post data from Drupal 9 when a content is created, post data to Drupal 7 hosted in a different server to create node content.

In Drupal7, I have enabled services module and created a resource to create login session, accept json data and creates node content. This is working fine when I test from POSTMAN.

I am new to Drupal 8/9 and not sure how to post json data to D7. Please could anyone suggest? so far, i have created a custom module in D9 and have added additional custom_form_submit where I can add code to post data once the node is submitted. I need to login to D7, grab token, post data to D7 to create node in D7, then logout from D7.

Or can the login process be handled separately via sysadmin configurations like proxy/firewall settings? Both D7 and D9 are hosted in separate servers but in same organisation cloud.

[updated] Our current D7 app has a lot of custom features used internally within our organisation and externally. We are in the process of migrating the app to D9 prioritising externally accessible features and to keep D7 as legacy system for internal use. We only need 5 fields in ONE cck in D9 to be stored in real time in D7 to continue using D7.

The 5 fields include integer, date&time and list fields. I have tried to maintain the cck and field machine names SAME in both D7 and D9 sites. The rest of the fields in this cck are very different in both sites.

7
  • Specifically, what kind of data are you trying to post? What is the relationship between the D7 site and the D9 site? Are they supposed to be "mirrors" of each other and have the same users, content, etc.? Or are they mostly separate sites with different content and users? In many cases, you can use the Feeds module to sync content between Drupal sites. Oct 21, 2021 at 7:04
  • please see question updated with answers for your questions. Syncing using Feeds module sounds much less work than web services. Would it work with different drupal version sites like between D7 and D9?
    – shablm
    Oct 21, 2021 at 12:27
  • Yes, Feeds will work with different Drupal versions, and even non-Drupal sites. It depends on what kind of access control you need, but in the simplest setup, you could create a view on the D9 site that outputs the data you need and point the D7 site to it and import it in Feeds on D7. Oct 21, 2021 at 12:49
  • Great! I will definitely try out Feeds module. Just another quick question regarding access control, all our forms and views are login protected and should not be accessible publicly. Would the view in D9 that outputs data could be configured to be accessed only by D7 / login etc?
    – shablm
    Oct 21, 2021 at 12:58
  • Yes, see the fetchers here: drupal.org/node/856644 Oct 21, 2021 at 13:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.