# Patch updates to a log by a user with non-default language fail w/ 405

**URL:** <https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473>\
**Category:** Development\
**Tags:** support-request\
**Created:** [January 12, 2023, 8:11am UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473 "2023-01-12T08:11:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [January 12, 2023, 8:11am UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/1 "2023-01-12T08:11:36Z")

</div>

I’m trying to send a PATCH to update a log from Node-Red  
Never updated a log before.  
But I end up with this error:  
 ![bilde](https://global.discourse-cdn.com/free1/uploads/farm_os/original/2X/e/ed6d6f14da8bfa51c4430928b8bee78065e8a261.png)

Not the kind of error I would expect…

```auto
msg.payload = {
    "data": {
        "type": "log-lab_test",
        "id": id_log,
        "attributes": {
            "name": "Jordprøve",
            "status": "done"
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [January 12, 2023, 9:58am UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/2 "2023-01-12T09:58:18Z")

</div>

Not sure about the message, but you need to Get the UUID of the log then include it in the patch, if I remember correctly. I’ll have a look for a patch example.

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [January 12, 2023, 10:03am UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/3 "2023-01-12T10:03:55Z")

</div>

Isn’t that the id of the log?  
as in id:“6b181bea-fa05-40f5-bb16-5cedd66a83fc” of the log?

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [January 12, 2023, 10:07am UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/4 "2023-01-12T10:07:48Z")

</div>

Yes, sorry…  
my bad, brain didn’t process the variable 🤪

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [January 12, 2023, 10:09am UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/5 "2023-01-12T10:09:27Z")

</div>

> [@Farmer-Ed](#):
>
> my bad, brain didn’t process the variable 🤪

processing is for computers, I think 😇

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [January 12, 2023, 10:11am UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/6 "2023-01-12T10:11:58Z")

</div>

> [@pat](#):
>
> `"type": "log-lab_test"`

```auto
"log--lab_test"

```

not

```auto
"log-lab_test"

```

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [January 12, 2023, 10:13am UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/7 "2023-01-12T10:13:46Z")

</div>

Yep. I know. Used – at first. Same error on both

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [January 12, 2023, 10:19am UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/9 "2023-01-12T10:19:57Z")

</div>

I guess the error states translations?  
is there any field in the API like “translation”:“en”

perhaps something different in your instance because you use translations?

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [January 12, 2023, 10:32am UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/10 "2023-01-12T10:32:38Z")

</div>

try patching to endpoint /no/log/lab\_test?

It could be a bug with translated sites:

> **[PATCH 405 for untranslatable content entities with different default language...](https://www.drupal.org/project/drupal/issues/3043168)**
>
> Hi, folks look like I having problems since \[#3038308\]. I can't PATCH my custom content entity since I updated module 2.3.0 =\> 2.4.0. I have a custom content entity type, which is not translatable. The site is installed on different from the...

might need @mstenta to have a look.

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [January 12, 2023, 10:37am UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/11 "2023-01-12T10:37:31Z")

</div>

> [@Farmer-Ed](#):
>
> /no/log/lab\_test

Nothing happens then.  
Propably a bug.

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [January 12, 2023, 10:46am UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/12 "2023-01-12T10:46:35Z")

</div>

Huh…  
Been using the same API node all over. Realised I had a farmOS API v2 node.  
Should propably do some house-cleaning…

Anyway : The v2 node gives this error when injecting the exact same payload.  
`TypeError: Cannot read properties of undefined (reading 'hasOwnProperty')`

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [January 12, 2023, 11:41am UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/13 "2023-01-12T11:41:21Z")

</div>

Yea, me too…

> [@pat](#):
>
> Anyway : The v2 node gives this error when injecting the exact same payload.  
> `TypeError: Cannot read properties of undefined (reading 'hasOwnProperty')`

Good to know @pat, will take note. The V2 is very much WIP,

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [January 12, 2023, 1:01pm UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/14 "2023-01-12T13:01:36Z")

</div>

@pat have you compared your post to the existing JSON at the API endpoint? to see if anything is translated?  
or tried including the appropriate langcode?

```auto
msg.payload = {
    "data": {
        "type": "log-lab_test",
        "id": id_log,
        "attributes": {
            "name": "Jordprøve",
            "status": "done"
            "langcode": "en"
        }
    }
}

```

or

```auto
msg.payload = {
    "data": {
        "type": "log-lab_test",
        "id": id_log,
        "attributes": {
            "name": "Jordprøve",
            "status": "done"
            "langcode": "no"
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [January 12, 2023, 3:32pm UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/15 "2023-01-12T15:32:11Z")

</div>

Well, we have this one:

```auto
"revision_translation_affected": true,

```

Does’nt seem to make any difference if it’s true or false.  
Experimented with all three settings.

```auto
"attributes": {
"drupal_internal__id": 1179,
"drupal_internal__revision_id": 948,
"langcode": "en",
"revision_created": "2023-01-11T15:43:52+00:00",
"revision_log_message": null,
"name": "Jordprøve",
"timestamp": "2023-01-11T12:40:51+00:00",
"status": "pending",
"created": "2023-01-11T12:40:51+00:00",
"changed": "2023-01-11T15:43:52+00:00",
"default_langcode": true,
"revision_translation_affected": true,
"data": null,
"notes": null,
"flag": [],
"is_group_assignment": false,
"geometry": null,
"is_movement": false,
"quick": [],
"lab_test_type": "soil",
"lab_received_date": "2023-01-18T00:01:01+00:00",
"lab_processed_date": null
},

```

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [January 16, 2023, 2:30pm UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/16 "2023-01-16T14:30:23Z")

</div>

Just catching up on this thread… not sure what the cause of the issue is yet (or if it’s a bug or not). I’m new to using Drupal localization/translation features too so we’ll be learning together. 😉

First thing to note: Drupal has two different “mechanisms” for localization. One is for “interface translations” (eg: all the UI text that comes in the module code), and one for “content translations” (eg: so you can have multiple versions of a record, each in a different language).

farmOS aims to support the former (interface translation), but not the latter (content translation), because we don’t foresee that being a need for most users (if you do need it, you are free to experiment with Drupal’s features yourself and report back), as opposed to cases where Drupal is used for a public-facing _website_ where you want your _content_ to be available to visitors in multiple languages.

The reason I’m outlining that is: from the perspective of API requests, I don’t think you should ever need to touch the `langcode` attribute or any other language attributes for that matter. The records you create/update via the API are considered “content” and therefore don’t support individual content translations (farmOS does not turn that module on).

I believe that’s why the error message states: “… modify one of the translations that do exist: en” - that is referring to _existing languages of the record you are updating_. Records (content) will always be the _default_ language of the site, which in the case of farmOS is always `en` (even if you write your notes/etc in another language).

(There is a technical reason why the default is always `en`, which you can learn more about here: [https://www.drupal.org/project/farm/issues/3257430](https://www.drupal.org/project/farm/issues/3257430))

So… back to the issue at hand…

In order to determine if this is a bug or not, I think we need to replicate it in as simple a form as possible, to isolate whether or not it is caused _only_ by the fact that @pat is using the `farm_l10n` module.

The way I would do this is: create a barebones API request that runs correctly on a non-translated instance, and then run that on @pat’s (or any instance with `farm_l10n` enabled) and see if the error occurs.

Based on the thread above, I’m not convinced that a “correct” API request was made yet. And I would prefer to see `curl` commands that are made outside of Node Red just to isolate that as a potential contributing factor.

@pat @Farmer-Ed would you two be able/interested in testing this out in that way together to see if we can get any clues?

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [January 16, 2023, 2:38pm UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/17 "2023-01-16T14:38:08Z")

</div>

Sure, I actually have some of @pats Soil Sample Data in my Dev instance already which has no translations, So I can do that when I get a chance a little later.

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [January 16, 2023, 2:57pm UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/18 "2023-01-16T14:57:15Z")

</div>

Actually had a moment to test now.

The payload worked without errors on an untranslated instance.  
I just added a UUID from my instance.

```auto
msg.payload = {
    "data": {
        "type": "log-lab_test",
        "id": "03979e6e-e6e6-44a9-8581-5a6ace4eec99",
        "attributes": {
            "name": "Jordprøve",
            "status": "done"
        }
    }
}

```

return msg;

 ![image](https://global.discourse-cdn.com/free1/uploads/farm_os/original/2X/7/779b2dd54fc80b9503f12c4bde37676fefd2af55.png)

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [January 16, 2023, 3:49pm UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/19 "2023-01-16T15:49:37Z")

</div>

Installed the Norwegian Language

and got

![image](https://global.discourse-cdn.com/free1/uploads/farm_os/original/2X/5/5be69e2a485bd0688c11041ca46aa52bba74ac78.png)

@pat try setting your users language to English and try again.

@mstenta Mine works fine in English but not Norwegian, haven’t tried other languages (not sure if that should matter?)

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [January 16, 2023, 3:56pm UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/20 "2023-01-16T15:56:25Z")

</div>

Oh. I’ll try that tonight.

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [January 16, 2023, 4:33pm UTC](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473/21 "2023-01-16T16:33:37Z")

</div>

> [@Farmer-Ed](#):
>
> @pat try setting your users language to English and try again.

Well, that worked

```auto
msg.payload = {
    "data": {
        "type": "log--lab_test",
        "id": uuid,
        "attributes": {
            "name": "Codetest",
            "status": "done"
        }
    }
}
    

```

[Next page](https://farmos.discourse.group/t/patch-updates-to-a-log-by-a-user-with-non-default-language-fail-w-405/1473.md?page=2)
