I'm making a JSON migration and it requires the header: Accept: 'application/json; charset=utf-8'
Here's my source configuration:
source:
plugin: url
data_fetcher_plugin: http
data_parser_plugin: json
authentication:
plugin: basic
username: ''
password: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
headers:
Accept: 'application/json; charset=utf-8'
Content-Type: 'application/json'
urls: https://www.example.com/jsonfeed
The authentication works, but the headers aren't passed though to getRequestHeaders()
The following patch fixes it for me, but I'm not sure whether this is a bug or not.
Here's what I've done:
Index: httpdocs/modules/contrib/migrate_plus/src/Plugin/migrate_plus/data_fetcher/Http.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- httpdocs/modules/contrib/migrate_plus/src/Plugin/migrate_plus/data_fetcher/Http.php (date 1485957865000)
+++ httpdocs/modules/contrib/migrate_plus/src/Plugin/migrate_plus/data_fetcher/Http.php (revision )
@@ -70,7 +70,7 @@
* {@inheritdoc}
*/
public function getRequestHeaders() {
- return !empty($this->headers) ? $this->headers : [];
+ return !empty($this->configuration['headers']) ? $this->configuration['headers'] : [];
}
/**
Comment | File | Size | Author |
---|---|---|---|
#3 | fix_headers-2849153-3.patch | 751 bytes | mErilainen |
Comments
Comment #2
joshi.rohit100@spencer95 - that looks like a bug that headers are not available but that should not affect migration. Here is sample json migration which worked for me without header info https://github.com/joshirohit100/migrate_training_json/blob/master/migra...
Comment #3
mErilainen CreditAttribution: mErilainen at Wunder commentedI came to same conclusion, with this patch I managed to read tweets from Twitter API, which requires a Bearer token to be passed and also requires the "Accept: application/json" header to be set.
Comment #4
jcnventura CreditAttribution: jcnventura at Wunder commentedMight be a duplicate of #2640512: Make custom headers an HTTP-specific feature
Comment #5
mikeryanYes, #2640512: Make custom headers an HTTP-specific feature should address this by referencing the configuration directly, thanks.